Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/candy-chat/candy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Klang <bklang@mojolingo.com>2015-04-07 05:20:50 +0300
committerBen Klang <bklang@mojolingo.com>2015-04-07 05:20:50 +0300
commitf4b6c6f595ffefe67add99931d47ad050f430cd6 (patch)
tree82ee6e7fcc7ec6e56dd4bbfcd8868157f40b044f
parent563680ee6d27900beb7068fb41cdd4f31b1f9769 (diff)
Fix incorrect JID resource with Websockets
This commit makes the connect function check the provided JID for a resource. Without this, Candy connects with the default resource of “Candy”, then causes a stream error when sending the first stanza with a from containing the full JID.
-rw-r--r--src/core.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core.js b/src/core.js
index a6f2fa8..2296205 100644
--- a/src/core.js
+++ b/src/core.js
@@ -284,6 +284,12 @@ Candy.Core = (function(self, Strophe, $) {
_anonymousConnection = !_anonymousConnection ? jidOrHost && jidOrHost.indexOf("@") < 0 : true;
if(jidOrHost && password) {
+ // Respect the resource, if provided
+ var resource = Strophe.getResourceFromJid(jidOrHost);
+ if (resource) {
+ _options.resource = resource;
+ }
+
// authentication
_connection.connect(_getEscapedJidFromJid(jidOrHost) + '/' + _options.resource, password, Candy.Core.Event.Strophe.Connect);
if (nick) {