Commit 36a875a4 authored by JC Brand's avatar JC Brand

Add stanza-specific event listener.

Therefore removing the `presence` event again.
parent 1c961ab4
......@@ -2,7 +2,8 @@
## 0.11.0 (Unreleased)
- Emit an event `presence` when a presence stanza is received. [jcbrand]
- Add stanza-specific event listener `converse.listen.stanza`.
As a result `converse.listen.on('message');` has been deprecated, use `converse.stanza.on('message');` instead. [jcbrand]
- Emit an event `chatBoxInitialized` once a chat box's initialize method has been called. [jcbrand]
- Emit an event `statusInitialized` once the user's own status has been initialized upon startup. [jcbrand]
- Split converse.js up into different plugin modules. [jcbrand]
......
......@@ -780,14 +780,10 @@ Here are the different events that are emitted:
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **initialized** | Once converse.js has been initialized. | ``converse.listen.on('initialized', function (event) { ... });`` |
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **message** | When a message is received. | ``converse.listen.on('message', function (event, messageXML) { ... });`` |
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **messageSend** | When a message will be sent out. | ``storage_memoryconverse.listen.on('messageSend', function (event, messageText) { ... });`` |
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **noResumeableSession** | When keepalive=true but there aren't any stored prebind tokens. | ``converse.listen.on('noResumeableSession', function (event) { ... });`` |
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **presence** | A presence stanza has been received. | ``converse.listen.on('presence', function (event, presenceStanza) { ... });`` |
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **reconnect** | After the connection has dropped. Converse.js will attempt to reconnect when not in prebind mode. | ``converse.listen.on('reconnect', function (event) { ... });`` |
+---------------------------------+---------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| **roomInviteSent** | After the user has sent out a direct invitation, to a roster contact, asking them to join a room. | ``converse.listen.on('roomInvite', function (event, data) { ... });`` |
......
......@@ -144,6 +144,18 @@
'not': function (evt, handler) {
converse.off(evt, handler);
},
'stanza': function (name, options, handler) {
options = options || {};
converse.connection.addHandler(
handler,
options.ns,
options.name,
options.type,
options.id,
options.from,
options
);
},
},
'send': function (stanza) {
converse.connection.send(stanza);
......
......@@ -1182,7 +1182,6 @@
this.addResource(bare_jid, resource);
contact.save({'chat_status': chat_status});
}
converse.emit('presence', presence);
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment