Class jabberwerx.ChatController
Extends
jabberwerx.Controller.
Controller class for chat functionality. Controls the creation and deletion of
ChatSession objects. Upon a message stanza been recieved, for which there is no
ChatSession object already created, a new ChatSession object is created and the
chatSessionOpened event fired. ChatSession's can be created directly using the
openChatSession method. The chatSessionClosed event is fired upon the closing of a
chat session.
This class provides the following events:
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
jabberwerx.ChatController(client)
Creates a new ChatController with the given client. |
| Field Attributes | Field Name and Description |
|---|---|
|
Used to determine if XEP-085 chat states will be sent upon chat state changes. |
- Fields borrowed from class jabberwerx.Controller:
- client, name
| Method Attributes | Method Name and Description |
|---|---|
|
closeSession(session)
Removes the ChatSession object from the active list. |
|
|
getSession(jid)
Get the ChatSession object for this jid if it exists. |
|
|
isPrivateMessage(jid)
Checks to see if the bare version of the jid passed in is a MUCRoom. |
|
|
openSession(jid, thread)
Creates a new ChatSession object, or returns an existing ChatSession object, to be used to communicate with the jid specified. |
- Methods borrowed from class jabberwerx.Controller:
- cleanupEntity, destroy, removeEntity, updateEntity
- Methods borrowed from class jabberwerx.JWModel:
- applyEvent, event, shouldBeSavedWithGraph
- Methods borrowed from class jabberwerx.JWBase:
- extend, getClassName, graphUnserialized, init, intercept, invocation, mixin, shouldBeSerializedInline, toString, wasUnserialized, willBeSerialized
Creates a new ChatController with the given client.
- Parameters:
- {jabberwerx.Client} client
- The client object to use for communicating to the server
- Throws:
- {TypeError}
- If {client} is not an instance of jabberwerx.Client
Used to determine if XEP-085 chat states will be sent upon chat state changes. If true, then chat state changes are sent, if false, then they are not sent. Defaults to true.
Removes the ChatSession object from the active list. Fire the chatSessionClosed event.
- Parameters:
- {jabberwerx.JID|String|jabberwerx.ChatSession} session
- The session to close
- Returns:
- {Boolean} true if successfully removed session, false otherwise
Get the ChatSession object for this jid if it exists.
- Parameters:
- {jabberwerx.JID|String} jid
- The resource component of the jid is ignored
- Returns:
- {jabberwerx.ChatSession} object or null if the ChatSession does not exist
Checks to see if the bare version of the jid passed in is a MUCRoom.
- Parameters:
- {jabberwerx.JID} jid
- The JID to check.
- Throws:
- {TypeError}
- if jid is not of type jabberwerx.JID
- Returns:
- {Boolean} true if the bare JID is a MUCRoom.
Creates a new ChatSession object, or returns an existing ChatSession object, to be used to communicate with the jid specified.
- Parameters:
- {jabberwerx.JID|String} jid
- The jid of the user with whom the ChatSession should be set up with.
- {String} thread Optional
- The thread to use in the outgoing messages. A random thread value will be generated if one is not provided. Note: the thread value can change during the duration of a chat session.
- Returns:
- {jabberwerx.ChatSesison} A new ChatSession object if an object for this jid does not already exist, otherwise returns the existing ChatSession object for this jid.