Add stanza-specific event listener.

Therefore removing the `presence` event again.
This commit is contained in:
JC Brand 2016-03-16 18:11:18 +00:00
parent 1c961ab4d1
commit 36a875a402
4 changed files with 14 additions and 6 deletions

View File

@ -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]

View File

@ -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) { ... });`` |

View File

@ -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);

View File

@ -1182,7 +1182,6 @@
this.addResource(bare_jid, resource);
contact.save({'chat_status': chat_status});
}
converse.emit('presence', presence);
}
});