event.js

CandyChats are not dead yet.

Authors

Copyright

© 2011 Amiado Group AG.  All rights reserved.  © 2012-2014 Patrick Stadler & Michael Weibel.  All rights reserved.

Summary
event.js
Candy.Core.EventChat Events
Functions
LoginNotify view that the login window should be displayed
Events
candy:core.loginTriggered when the login window should be displayed
Candy.Core.Event.StropheStrophe-related events
Functions
ConnectActs on strophe status events and notifies view.
Events
candy:core.chat.connectionConnection status updates
Candy.Core.Event.JabberJabber related events
Functions
VersionResponds to a version request
PresenceActs on a presence event
Events
candy:core.presencePresence updates.
Functions
BookmarksActs on a bookmarks event.
PrivacyListActs on a privacy list event and sets up the current privacy list of this user.
PrivacyListErrorActs when a privacy list error has been received.
MessageActs on room, admin and server messages and notifies the view if required.
Events
candy:core:chat:inviteIncoming chat invite for a MUC.
candy:core:chat:inviteIncoming chat invite for a MUC.
candy:core:chat:message:normalMessages with the type attribute of normal or those that do not have the optional type attribute.
candy:core:chat:message:otherMessages with a type other than the ones listed in RFC3921 section 2.1.1.
candy:core.chat.message.adminAdmin message
candy:core.chat.message.serverServer message (e.g.
Candy.Core.Event.Jabber.RoomRoom specific events
Functions
LeaveLeaves a room and cleans up related data and notifies view.
Events
candy:core.presence.leaveWhen the local client leaves a room
Functions
DiscoSets informations to rooms according to the disco info received.
PresenceActs on various presence messages (room leaving, room joining, error presence) and notifies view.
Events
candy:core.presence.roomRoom presence updates
Functions
PresenceErrorActs when a presence of type error has been retrieved.
Events
candy:core.presence.errorTriggered when a presence error happened
Functions
MessageActs on various message events (subject changed, private chat message, multi-user chat message) and notifies view.
Events
candy:core.message.chatstateTriggers on any recieved chatstate notification.
candy:core.messageTriggers on various message events (subject changed, private chat message, multi-user chat message).

Candy.Core.Event

Chat Events

Parameters

(Candy.Core.Event) selfitself
(Strophe) StropheStrophe
(jQuery) $jQuery
Summary
Functions
LoginNotify view that the login window should be displayed
Events
candy:core.loginTriggered when the login window should be displayed

Functions

Login

self.Login = function(presetJid)

Notify view that the login window should be displayed

Parameters

(String) presetJidPreset user JID

Triggers

candy:core.login using {presetJid}

Events

candy:core.login

Triggered when the login window should be displayed

Parameters

(String) presetJidPreset user JID

Candy.Core.Event.Strophe

Strophe-related events

Summary
Functions
ConnectActs on strophe status events and notifies view.
Events
candy:core.chat.connectionConnection status updates

Functions

Connect

Connect: function(status)

Acts on strophe status events and notifies view.

Parameters

(Strophe.Status) statusStrophe statuses

Triggers

candy:core.chat.connection using {status}

Events

candy:core.chat.connection

Connection status updates

Parameters

(Strophe.Status) statusStrophe status

Candy.Core.Event.Jabber

Jabber related events

Summary
Functions
VersionResponds to a version request
PresenceActs on a presence event
Events
candy:core.presencePresence updates.
Functions
BookmarksActs on a bookmarks event.
PrivacyListActs on a privacy list event and sets up the current privacy list of this user.
PrivacyListErrorActs when a privacy list error has been received.
MessageActs on room, admin and server messages and notifies the view if required.
Events
candy:core:chat:inviteIncoming chat invite for a MUC.
candy:core:chat:inviteIncoming chat invite for a MUC.
candy:core:chat:message:normalMessages with the type attribute of normal or those that do not have the optional type attribute.
candy:core:chat:message:otherMessages with a type other than the ones listed in RFC3921 section 2.1.1.
candy:core.chat.message.adminAdmin message
candy:core.chat.message.serverServer message (e.g.

Functions

Version

Version: function(msg)

Responds to a version request

Parameters

(String) msgRaw XML Message

Returns

(Boolean)true

Presence

Presence: function(msg)

Acts on a presence event

Parameters

(String) msgRaw XML Message

Triggers

candy:core.presence using {from, stanza}

Returns

(Boolean)true

Events

candy:core.presence

Presence updates.  Emitted only when not a muc presence.

Parameters

(JID) fromFrom Jid
(String) stanzaStanza

Functions

Bookmarks

Bookmarks: function(msg)

Acts on a bookmarks event.  When a bookmark has the attribute autojoin set, joins this room.

Parameters

(String) msgRaw XML Message

Returns

(Boolean)true

PrivacyList

PrivacyList: function(msg)

Acts on a privacy list event and sets up the current privacy list of this user.

If no privacy list has been added yet, create the privacy list and listen again to this event.

Parameters

(String) msgRaw XML Message

Returns

(Boolean)false to disable the handler after first call.

PrivacyListError

PrivacyListError: function(msg)

Acts when a privacy list error has been received.

Currently only handles the case, when a privacy list doesn’t exist yet and creates one.

Parameters

(String) msgRaw XML Message

Returns

(Boolean)false to disable the handler after first call.

Message

Message: function(msg)

Acts on room, admin and server messages and notifies the view if required.

Parameters

(String) msgRaw XML Message

Triggers

candy:core.chat.message.admin using {type, message} candy:core.chat.message.server {type, subject, message}

Returns

(Boolean)true

Events

candy:core:chat:invite

Incoming chat invite for a MUC.

Parameters

(String) roomJidThe room the invite is to
(String) fromUser JID that invite is from text
(String) reasonReason for invite [default: ‘’]
(String) passwordPassword for the room [default: null]
(String) continuedThreadThe thread ID if this is a continuation of a 1-on-1 chat [default: null]

candy:core:chat:invite

Incoming chat invite for a MUC.

Parameters

(String) roomJidThe room the invite is to
(String) fromUser JID that invite is from text
(String) reasonReason for invite [default: ‘’]
(String) passwordPassword for the room [default: null]
(String) continuedThreadThe thread ID if this is a continuation of a 1-on-1 chat [default: null]

candy:core:chat:message:normal

Messages with the type attribute of normal or those that do not have the optional type attribute.

Parameters

(String) typeType of the message [default: message]
(Object) messageMessage object.

candy:core:chat:message:other

Messages with a type other than the ones listed in RFC3921 section 2.1.1.  This allows plugins to catch custom message types.

Parameters

(String) typeType of the message [default: message]
(Object) messageMessage object.

candy:core.chat.message.admin

Admin message

Parameters

(String) typeType of the message [default: message]
(String) messageMessage text

candy:core.chat.message.server

Server message (e.g. subject)

Parameters

(String) typeMessage type [default: message]
(String) subjectSubject text
(String) messageMessage text

Candy.Core.Event.Jabber.Room

Room specific events

Summary
Functions
LeaveLeaves a room and cleans up related data and notifies view.
Events
candy:core.presence.leaveWhen the local client leaves a room
Functions
DiscoSets informations to rooms according to the disco info received.
PresenceActs on various presence messages (room leaving, room joining, error presence) and notifies view.
Events
candy:core.presence.roomRoom presence updates
Functions
PresenceErrorActs when a presence of type error has been retrieved.
Events
candy:core.presence.errorTriggered when a presence error happened
Functions
MessageActs on various message events (subject changed, private chat message, multi-user chat message) and notifies view.
Events
candy:core.message.chatstateTriggers on any recieved chatstate notification.
candy:core.messageTriggers on various message events (subject changed, private chat message, multi-user chat message).

Functions

Leave

Leave: function(msg)

Leaves a room and cleans up related data and notifies view.

Parameters

(String) msgRaw XML Message

Triggers

candy:core.presence.leave using {roomJid, roomName, type, reason, actor, user}

Returns

(Boolean)true

Events

candy:core.presence.leave

When the local client leaves a room

Also triggered when the local client gets kicked or banned from a room.

Parameters

(String) roomJidRoom
(String) roomNameName of room
(String) typePresence type [kick, ban, leave]
(String) reasonWhen type equals kick|ban, this is the reason the moderator has supplied.
(String) actorWhen type equals kick|ban, this is the moderator which did the kick
(Candy.Core.ChatUser) useruser which leaves the room

Functions

Disco

Disco: function(msg)

Sets informations to rooms according to the disco info received.

Parameters

(String) msgRaw XML Message

Returns

(Boolean)true

Presence

Presence: function(msg)

Acts on various presence messages (room leaving, room joining, error presence) and notifies view.

Parameters

(Object) msgjQuery object of XML message

Triggers

candy:core.presence.room using {roomJid, roomName, user, action, currentUser}

Returns

(Boolean)true

Events

candy:core.presence.room

Room presence updates

Parameters

(String) roomJidRoom JID
(String) roomNameRoom name
(Candy.Core.ChatUser) userUser which does the presence update
(String) actionAction [kick, ban, leave, join]
(Candy.Core.ChatUser) currentUserCurrent local user

Functions

PresenceError

PresenceError: function(msg)

Acts when a presence of type error has been retrieved.

Parameters

(Object) msgjQuery object of XML message

Triggers

candy:core.presence.error using {msg, type, roomJid, roomName}

Returns

(Boolean)true

Events

candy:core.presence.error

Triggered when a presence error happened

Parameters

(Object) msgjQuery object of XML message
(String) typeError type
(String) roomJidRoom jid
(String) roomNameRoom name

Functions

Message

Message: function(msg)

Acts on various message events (subject changed, private chat message, multi-user chat message) and notifies view.

Parameters

(String) msgjQuery object of XML message

Triggers

candy:core.message using {roomJid, message, timestamp}

Returns

(Boolean)true

Events

candy:core.message.chatstate

Triggers on any recieved chatstate notification.

The resulting message object contains the name of the person, the roomJid, and the indicated chatstate.

The following lists explain those parameters

Message Object Parameters

(String) nameUser name
(String) roomJidRoom jid
(String) chatstateChatstate being indicated.  (“paused”, “inactive”, “composing”, “gone”)

TODO

Perhaps handle blank “active” as specified by XEP-0085?

candy:core.message

Triggers on various message events (subject changed, private chat message, multi-user chat message).

The resulting message object can contain different key-value pairs as stated in the documentation of the parameters itself.

The following lists explain those parameters

Message Object Parameters

(String) nameRoom name
(String) bodyMessage text
(String) typeMessage type ([normal, chat, groupchat]) or ‘info’ which is used internally for displaying informational messages
(Boolean) isNoConferenceRoomJidif a 3rd-party client sends a direct message to this user (not via the room) then the username is the node and not the resource.  This flag tells if this is the case.

Parameters

(String) roomJidRoom jid
(Object) messageDepending on what kind of message, the object consists of different key-value pairs:
  • Room Subject: {name, body, type}
  • Error message: {type = ‘info’, body}
  • Private chat message: {name, body, type, isNoConferenceRoomJid}
  • MUC msg from a user: {name, body, type}
  • MUC msg from server: {name = ‘’, body, type = ‘info’}
(String) timestampTimestamp, only when it’s an offline message

TODO

Streamline those events sent and rename the parameters.

self.Login = function(presetJid)
Notify view that the login window should be displayed
Connect: function(status)
Acts on strophe status events and notifies view.
Version: function(msg)
Responds to a version request
Presence: function(msg)
Acts on a presence event
Bookmarks: function(msg)
Acts on a bookmarks event.
PrivacyList: function(msg)
Acts on a privacy list event and sets up the current privacy list of this user.
PrivacyListError: function(msg)
Acts when a privacy list error has been received.
Message: function(msg)
Acts on room, admin and server messages and notifies the view if required.
Leave: function(msg)
Leaves a room and cleans up related data and notifies view.
Disco: function(msg)
Sets informations to rooms according to the disco info received.
Presence: function(msg)
Acts on various presence messages (room leaving, room joining, error presence) and notifies view.
PresenceError: function(msg)
Acts when a presence of type error has been retrieved.
Message: function(msg)
Acts on various message events (subject changed, private chat message, multi-user chat message) and notifies view.
Close