Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open/close instead of stream:stream #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ if the *callback=* GET query parameter is supplied.

* [http://xmpp.org/extensions/xep-0124.html](http://xmpp.org/extensions/xep-0124.html)
* [http://xmpp.org/extensions/xep-0206.html](http://xmpp.org/extensions/xep-0206.html)
* [http://tools.ietf.org/html/draft-moffitt-xmpp-over-websocket-00](http://tools.ietf.org/html/draft-moffitt-xmpp-over-websocket-00)
* [https://tools.ietf.org/html/draft-ietf-xmpp-websocket-10](https://tools.ietf.org/html/draft-ietf-xmpp-websocket-10)


### Dependencies
Expand Down Expand Up @@ -278,6 +278,7 @@ if the *callback=* GET query parameter is supplied.
4. libpurple (pidgin as a client)
5. [strophe.js websocket client] (https://github.com/superfeedr/strophejs/tree/protocol-ed) [broken link]
6. [node-xmpp] (https://github.com/astro/node-xmpp)
7. [stanza.io] (https://github.com/otalk/stanza.io)


### Tested using
Expand Down
13 changes: 6 additions & 7 deletions src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ exports.createServer = function(bosh_server, options, webSocket) {

wsep.on('stream-added', function(sstate) {
var to = sstate.to || '';
var ss_xml = new ltx.Element('stream:stream', {
'xmlns': 'jabber:client',
'xmlns:stream': 'http://etherx.jabber.org/streams',
var ss_xml = new ltx.Element('open', {
'xmlns': 'urn:ietf:params:xml:ns:xmpp-framing',
'version': '1.0',
'xml:lang': 'en',
'from': to
Expand Down Expand Up @@ -234,7 +233,7 @@ exports.createServer = function(bosh_server, options, webSocket) {
message += XML_STREAM_CLOSE;
sstate.has_open_stream_tag = true;
}
} else if (message.indexOf(XML_STREAM_CLOSE) !== -1) {
} else if (message.indexOf(XML_STREAM_CLOSE) !== -1 || message.indexOf('<close') !== -1) {
// Stream close message from a client must appear in a message
// by itself - see draft-moffitt-xmpp-over-websocket-02
if (sstate.stream_state === STREAM_CLOSED) {
Expand All @@ -254,7 +253,7 @@ exports.createServer = function(bosh_server, options, webSocket) {
} else {
// Raise the stream-terminate event on wsep
wsep.emit('stream-terminate', sstate);
wsep.emit('response', XML_STREAM_CLOSE, sstate);
wsep.emit('response', '<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />', sstate);
sstate.terminated = true;
}
return;
Expand All @@ -280,13 +279,13 @@ exports.createServer = function(bosh_server, options, webSocket) {
// The stream start node is special since we trigger a
// stream-add event when we get it.
var ss_node = nodes.filter(function(node) {
return typeof node.is === 'function' && node.is('stream');
return typeof node.is === 'function' && (node.is('stream') || node.is('open'));
});

ss_node = us.first(ss_node);

nodes = nodes.filter(function(node) {
return typeof node.is === 'function' ? !node.is('stream') : true;
return typeof node.is === 'function' ? !(node.is('stream') || node.is('open')) : true;
});

if (ss_node) {
Expand Down