Class Index | Minimal

Classes


Class jabberwerx.MUCRoom


Extends jabberwerx.Entity.

Represents a Multi-User Chat (MUC) room.

This entity has the following in its #properties map:

NameTypeDescription
subjectStringThe room's subject

This class provides the following events:

Class Summary
Constructor Attributes Constructor Name and Description
 
jabberwerx.MUCRoom(jid, ctrl)

Creates a new instance of MUCRoom with the given JID and MUCController.

Field Summary
Field Attributes Field Name and Description
<static> <constant>  
jabberwerx.MUCRoom.DefaultInviteReason
<static> <constant>  
jabberwerx.MUCRoom.DefaultSubjectChange
 
me

The MUCOccupant representing the current user.

 

The cache of MUCOccupants for this room.

<static>  
jabberwerx.MUCRoom.RoomActiveError

Error thrown when attempting to enter a room that is already active.

<static>  
jabberwerx.MUCRoom.RoomNotActiveError

Error thrown when attempting operations on an inactive room.

Fields borrowed from class jabberwerx.Entity:
features, identities, jid, node, properties
Method Summary
Method Attributes Method Name and Description
 
applyConfig(configForm, configCallback)

Set the room's configuration.

 
changeNickname(nick, cb)

Changes the current user's nickname with the room.

 
changeSubject(subject, cb)

Changes or clears the subject in the room.

 

Destroys this MUCRoom.

 
enter(nick, enterArgs)

Enters this MUC room.

 
exit()

Exits this room.

 
fetchConfig(configCallback)

Fetch the room's configuration.

 

Retrieves the display name of this MUCRoom.

 

Retrieves the primary presence for this entity.

 
invite(toJids, reason, mediated)

Send an invite from this room to specified jids.

 

Determines if this room is currently active.

 

Sends a broadcast message to the room.

 

Override of the base to prevent display name changes.

 
updatePresence(presence)

Updates for this Entity.

Methods borrowed from class jabberwerx.Entity:
apply, getAllPresence, getGroups, getResourcePresence, hasFeature, hasIdentity, matches, remove, setGroups, toString, update
Methods borrowed from class jabberwerx.JWModel:
applyEvent, event, shouldBeSavedWithGraph
Methods borrowed from class jabberwerx.JWBase:
getClassName, graphUnserialized, init, invocation, shouldBeSerializedInline, wasUnserialized, willBeSerialized
Class Detail
jabberwerx.MUCRoom(jid, ctrl)

Creates a new instance of MUCRoom with the given JID and MUCController.

NOTE: This type should not be directly created. Instead, users should call jabberwerx.MUCController#room to obtain an instance.

Parameters:
{jabberwerx.JID|String} jid
The JID of the room.
{jabberwerx.MUCController} ctrl
The owning MUCController.
Throws:
{TypeError}
If {ctrl} is not a valid MUCController
{jabberwerx.JID.InvalidJIDError}
if {jid} is not an instance of jabberwerx.JID, and cannot be converted to one
Field Detail
<static> <constant> jabberwerx.MUCRoom.DefaultInviteReason

<static> <constant> jabberwerx.MUCRoom.DefaultSubjectChange

{jabberwerx.MUCOccupant} me

The MUCOccupant representing the current user.


{jabberwerx.MUCOccupantCache} occupants

The cache of MUCOccupants for this room. This is the source for the "entityCreated", "entityUpdated", "entityRenamed", and "entityDestroyed" events on MUCOccupants.


<static> jabberwerx.MUCRoom.RoomActiveError

Error thrown when attempting to enter a room that is already active.


<static> jabberwerx.MUCRoom.RoomNotActiveError

Error thrown when attempting operations on an inactive room.

Method Detail
applyConfig(configForm, configCallback)

Set the room's configuration. Use the given jabberwerx.XDataForm (or a generated cancel form if null) to update the room's configuration. Fires the optional callback on result.

The optional function {configCallback} is expected to match the following signature:

function callback(err) {
    err;       //Error explaining the failure,
                 //undefined if set succeeded
}
Errors may be jabberwerx.Stanza.ERR_REMOTE_SERVER_TIMEOUT if the attempt times out, or any error node found in the result.

Parameters:
{jabberwerx.XDataForm} configForm
The xdata configuration to set, may be null.
{Function} configCallback Optional
Callback fired on attempt completion.
Throws:
{TypeError}
If callback is defined but not a function or form is defined but not an XDataForm.
{jabberwerx.MUCRoom.RoomNotActiveError}
If room is not entered (or attempting entry)

changeNickname(nick, cb)

Changes the current user's nickname with the room. This method sends the necessary protocol, that ultimately results an "entityRenamed" event being triggered for the user's occupant.

The optional function {cb} is expected to match the following signature:

function callback(err) {
    this;    //refers to this room
    err;     //if entering failed, this is the error
             //explaining the failure, undefined if
             //entering succeeded
}

If the user's nickname in the room is already {nick}, this method does nothing.

Parameters:
{String} nick
The new nickname
{Function} cb Optional
The function to callback on when the change nickname attempt succeeds or fails.
Throws:
{TypeError}
if {cb} is not a valid function or undefined; or if {nick} is not a non-empty string
{jabberwerx.MUCRoom.RoomNotActiveError}
if the room is not currently active.

changeSubject(subject, cb)

Changes or clears the subject in the room. This method sends the necessary protocol, that results in the following events:

  1. triggers a "beforeRoomSubjectChanging" event with the candidate jabberwerx.Message, just prior to sending; This allows for the subject changing protocol to be modified.
  2. triggers a "roomSubjectChanging" event just after the subject changing protocol is sent.
  3. triggers a "roomSubjectChanged" event when the room broadcasts the change to all occupants (including the current user).
  4. triggers an "entityUpdated" event after the local subject property is changed.

The optional function {cb} is expected to match the following signature:

function callback(err) {
    this;    //refers to this room
    err;     //if entering failed, this is the error
             //explaining the failure, undefined if
             //entering succeeded
}

Parameters:
{String} subject
The new subject
{Function} cb Optional
The function to callback on when the change subject attempt succeeds or fails.
Throws:
{TypeError}
if {cb} is not a valid function or undefined
{jabberwerx.MUCRoom.RoomNotActiveError}
if the room is not currently active.

destroy()

Destroys this MUCRoom. This method overrides the base to unbind callbacks.


enter(nick, enterArgs)

Enters this MUC room. This method enters existing rooms or creates new ones as needed. New rooms are configurable through this method's callbacks

{enterArgs} may be either a callback function or an object that may contain mapped functions and other room specific entry data like a password . If {enterArgs} is a function it is expected to match the following signature:

function callback(err) {
    this;    //refers to this room
    err;     //if entering failed, this is the jabberwerx.Stanza.ErrorInfo
             //explaining the failure, undefined if
             //entering succeeded
}

If {enterArgs} is an object it may define any of the following:

     successCallback: function() {
         this; //refers to this room
     }
     errorCallback: function(err, aborted) {
         this; //refers to this room
         err; //jabberwerx.Stanza.ErrorInfo
         aborted //Boolean Room creation was user aborted before configuration was complete
     }
     configureCallback: function() {
         this; //refers to this room
     }

{enterArgs} may also contain a String password property that contains a plaintext password. for example:

 room.enter("foo@bar", {password: "foopass"})
The password is sent in the clear. A not-authorized error wil be fired (through errorCallback) if the password is invalid or not provided) and required.

The successCallback callback is called and a "roomEntered" event fired once the room has been successfully entered or, if a new room, created and configured. If the configureCallback callback is defined and invoked the callee must call #applyConfig to continue creating the room. A "roomCreated" event is fired when the room has been created but before configuration. Canceling a configuration during room creation cancels the creation of the room. NOTE successCallback and errorCallback are not called if the create is canceled. If {enterArgs} is a function or configureCallback is not defined the default configuration is used to create the room.

If a second enter (with the same nick) is attempted the the method calls successCallback immediately and returns.

Parameters:
{String} nick
The nickname to use in this room
{Function|Object} enterArgs Optional
The function (or map of functions)to callback on if entering succeeded, failed or an intermediate state like configuring.
Throws:
{TypeError}
If {enterArgs} is defined and is not a valid function, or an object, or if {nick} is not a non-empty string.
{jabberwerx.MUCRoom.RoomActiveError}
If the room for {jid} is already active, and nickname different from {nick} was used to enter it or if room is currently trying to enter.
{jabberwerx.Client.NotConnectedError}
If the client is not connected

exit()

Exits this room. This method sends the unavailable presence to the room, and eventually triggers a "roomExited" event.


fetchConfig(configCallback)

Fetch the room's configuration. Fetch the room's configuration jabberwerx.XDataForm and fire callback on result. The callback is passed either the fetched form or an error.

The optional function {configCallback} is expected to match the following signature:

function callback(form, err) {
    form;    //the fetched jabberwerx.XDataForm
                 //null if fetch failed
    err;       //Error explaining the failure,
                 //undefined if fetch succeeded
}
Errors may be jabberwerx.Stanza.ERR_REMOTE_SERVER_TIMEOUT if the fetch times out, or any error node found in the fetch result.

Parameters:
{Function} configCallback
Callback fired when fetch is completed.
Throws:
{TypeError}
If callback is undefined or not a function.
{jabberwerx.MUCRoom.RoomNotActiveError}
If room has not entered (or attempted entry)

{String} getDisplayName()

Retrieves the display name of this MUCRoom. This method overrides the base to always return the node portion of the room's JID.

Returns:
{String} The display name of this Room

{jabberwerx.Presence} getPrimaryPresence()

Retrieves the primary presence for this entity. This implementation always returns the presence for the current user in the room, or null if the room is not active.

Returns:
{jabberwerx.Presence} The primary presence for the room

{JID[]} invite(toJids, reason, mediated)

Send an invite from this room to specified jids.

Send an invite to each specified jid using the given reason. Invite may be sent through the room (via XEP 0045 7.5.2) or directly to the given jids (via xep 0249). Invalid jids are ignored. This method will return a list of all jids sent invites. {reason} defaults to jabberwerx.MUCRoom.DefaultInviteReason

Parameters:
{JID | String | JID[] | String[]} toJids
List or single (full or bare) jid(s)
{String} reason Optional
Message to send along with invite
{Boolean} mediated Optional
Send invite through conference server if possible
Throws:
{jabberwerx.MUCRoom.RoomNotActiveError}
if the room is not currently active.
Returns:
{JID[]} List of bare jids we succesfully sent invites

{Boolean} isActive()

Determines if this room is currently active. This implementation returns true an occupant for the current user exists, and has an available presence for that occupant.

Returns:
{Boolean} true if the room is active

sendBroadcast(msg)

Sends a broadcast message to the room. This method sends the necessary protocol, and results in the following events:

  1. triggers a "beforeRoomBroadcastSent" event with the candidate jabberwerx.Message, just prior to sending; This allows for the broadcast protocol to be modified.
  2. triggers a "roomBroadcastSent" event just after the broadcast protocol is sent.
  3. triggers a "roomBroadcastReceived" event when the room broadcasts the message to all occupants (including the current user).
msg may be plaintext, a root HTML element, a body element in the XHTML namespace (see xep-71) or an array of HTML tags. see jabberwerx.Message#setHTML for additional information.
Parameters:
{String|DOM|Array} msg
The message to send
Throws:
{jabberwerx.MUCRoom.RoomNotActiveError}
if the room is not currently active.

setDisplayName(name)

Override of the base to prevent display name changes.

Parameters:
{String} name Optional
The new display name (ignored)

{Boolean} updatePresence(presence)

Updates for this Entity. This method overrides the base to update presence for the room's occupants via jabberwerx.MUCOccupant#updatePresence, with the following additional actions:

Parameters:
{jabberwerx.Presence} presence
The presence to update from
Throws:
{TypeError}
If {presence} is not appropriate for this MUCRoom
Returns:
{Boolean} true if the presence updated the current user's occupant

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 02 2014 13:23:42 GMT-0600 (MDT)