Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Fix caps node to be candy url & reset submodule for strophe to be on …
Browse files Browse the repository at this point in the history
…the standard strophe.js version
  • Loading branch information
mweibel committed Jan 10, 2014
1 parent 45e04e1 commit 1fede7f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = git://github.com/recurser/jquery-i18n.git
[submodule "libs/strophejs"]
path = libs/strophejs
url = git://github.com/candy-chat/strophejs.git
url = git://github.com/strophe/strophejs.git
[submodule "libs/strophejs-plugins"]
path = libs/strophejs-plugins
url = git://github.com/strophe/strophejs-plugins.git
Expand Down
14 changes: 9 additions & 5 deletions candy.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var Candy = (function(self, $) {
*/
self.about = {
name: 'Candy',
version: '1.5.1-dev'
version: '1.6.0-beta1'
};

/** Function: init
Expand Down Expand Up @@ -153,7 +153,7 @@ Candy.Core = (function(self, Strophe, $) {
* Initialize Core.
*
* Parameters:
* (String) service - URL of BOSH service
* (String) service - URL of BOSH/Websocket service
* (Object) options - Options for candy
*/
self.init = function(service, options) {
Expand All @@ -174,11 +174,15 @@ Candy.Core = (function(self, Strophe, $) {
}

_addNamespaces();
// Connect to BOSH service

// Connect to BOSH/Websocket service
_connection = new Strophe.Connection(_service);
_connection.rawInput = self.rawInput.bind(self);
_connection.rawOutput = self.rawOutput.bind(self);

// set caps node
_connection.caps.node = 'https://candy-chat.github.io/candy/';

// Window unload handler... works on all browsers but Opera. There is NO workaround.
// Opera clients getting disconnected 1-2 minutes delayed.
if (!_options.disableWindowUnload) {
Expand Down Expand Up @@ -230,7 +234,7 @@ Candy.Core = (function(self, Strophe, $) {
* Triggered before a connection attempt is made.
*
* Plugins should register their stanza handlers using this event
* to ensure that they are set.
* to ensure that they are set.
*
* See also <#84 at https://github.com/candy-chat/candy/issues/84>.
*
Expand Down Expand Up @@ -425,7 +429,7 @@ Candy.Core = (function(self, Strophe, $) {
self.onWindowUnload = function() {
// Enable synchronous requests because Safari doesn't send asynchronous requests within unbeforeunload events.
// Only works properly when following patch is applied to strophejs: https://github.com/metajack/strophejs/issues/16/#issuecomment-600266
_connection._options.sync = true;
_connection.options.sync = true;
self.disconnect();
_connection.flush();
};
Expand Down
2 changes: 1 addition & 1 deletion candy.min.js

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions libs/libs.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ Strophe = {
* The version of the Strophe library. Unreleased builds will have
* a version of head-HASH where HASH is a partial revision.
*/
VERSION: "d79e10c",
VERSION: "a1f13b2",

/** Constants: XMPP Namespace Constants
* Common namespace constants from the XMPP RFCs and XEPs.
Expand Down Expand Up @@ -2060,6 +2060,8 @@ Strophe.TimedHandler.prototype = {
*
* > var conn = new Strophe.Connection("/http-bind/");
*
* WebSocket options:
*
* If you want to connect to the current host with a WebSocket connection you
* can tell Strophe to use WebSockets through a "protocol" attribute in the
* optional options parameter. Valid values are "ws" for WebSocket and "wss"
Expand All @@ -2068,13 +2070,23 @@ Strophe.TimedHandler.prototype = {
*
* > var conn = new Strophe.Connection("/xmpp-websocket/", {protocol: "wss"});
*
* Note that relative URLs starting _NOT_ with a "/" will also include the path
* Note that relative URLs _NOT_ starting with a "/" will also include the path
* of the current site.
*
* Also because downgrading security is not permitted by browsers, when using
* relative URLs both BOSH and WebSocket connections will use their secure
* variants if the current connection to the site is also secure (https).
*
* BOSH options:
*
* by adding "sync" to the options, you can control if requests will
* be made synchronously or not. The default behaviour is asynchronous.
* If you want to make requests synchronous, make "sync" evaluate to true:
* > var conn = new Strophe.Connection("/http-bind/", {sync: true});
* You can also toggle this on an already established connection:
* > conn.options.sync = true;
*
*
* Parameters:
* (String) service - The BOSH or WebSocket service URL.
* (Object) options - A hash of configuration options
Expand All @@ -2088,8 +2100,8 @@ Strophe.Connection = function (service, options)
this.service = service;

// Configuration options
this._options = options || {};
var proto = this._options.protocol || "";
this.options = options || {};
var proto = this.options.protocol || "";

// Select protocal based on service or options
if (service.indexOf("ws:") === 0 || service.indexOf("wss:") === 0 ||
Expand Down Expand Up @@ -4480,7 +4492,7 @@ Strophe.Bosh.prototype = {
"." + req.sends + " posting");

try {
req.xhr.open("POST", this._conn.service, this._conn._options.sync ? false : true);
req.xhr.open("POST", this._conn.service, this._conn.options.sync ? false : true);
} catch (e2) {
Strophe.error("XHR open failed.");
if (!this._conn.connected) {
Expand All @@ -4495,8 +4507,8 @@ Strophe.Bosh.prototype = {
// or on a gradually expanding retry window for reconnects
var sendFunc = function () {
req.date = new Date();
if (self._conn._options.customHeaders){
var headers = self._conn._options.customHeaders;
if (self._conn.options.customHeaders){
var headers = self._conn.options.customHeaders;
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
req.xhr.setRequestHeader(header, headers[header]);
Expand Down Expand Up @@ -4728,7 +4740,7 @@ Strophe.Websocket = function(connection) {
// URL together from options, current URL and the path.
var new_service = "";

if (connection._options.protocol === "ws" && window.location.protocol !== "https:") {
if (connection.options.protocol === "ws" && window.location.protocol !== "https:") {
new_service += "ws";
} else {
new_service += "wss";
Expand Down
4 changes: 2 additions & 2 deletions libs/libs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/strophejs
Submodule strophejs updated 3 files
+3 −3 src/bosh.js
+15 −3 src/core.js
+1 −1 src/websocket.js
2 changes: 1 addition & 1 deletion libs/strophejs-plugins
12 changes: 8 additions & 4 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Candy.Core = (function(self, Strophe, $) {
* Initialize Core.
*
* Parameters:
* (String) service - URL of BOSH service
* (String) service - URL of BOSH/Websocket service
* (Object) options - Options for candy
*/
self.init = function(service, options) {
Expand All @@ -117,11 +117,15 @@ Candy.Core = (function(self, Strophe, $) {
}

_addNamespaces();
// Connect to BOSH service

// Connect to BOSH/Websocket service
_connection = new Strophe.Connection(_service);
_connection.rawInput = self.rawInput.bind(self);
_connection.rawOutput = self.rawOutput.bind(self);

// set caps node
_connection.caps.node = 'https://candy-chat.github.io/candy/';

// Window unload handler... works on all browsers but Opera. There is NO workaround.
// Opera clients getting disconnected 1-2 minutes delayed.
if (!_options.disableWindowUnload) {
Expand Down Expand Up @@ -173,7 +177,7 @@ Candy.Core = (function(self, Strophe, $) {
* Triggered before a connection attempt is made.
*
* Plugins should register their stanza handlers using this event
* to ensure that they are set.
* to ensure that they are set.
*
* See also <#84 at https://github.com/candy-chat/candy/issues/84>.
*
Expand Down Expand Up @@ -368,7 +372,7 @@ Candy.Core = (function(self, Strophe, $) {
self.onWindowUnload = function() {
// Enable synchronous requests because Safari doesn't send asynchronous requests within unbeforeunload events.
// Only works properly when following patch is applied to strophejs: https://github.com/metajack/strophejs/issues/16/#issuecomment-600266
_connection._options.sync = true;
_connection.options.sync = true;
self.disconnect();
_connection.flush();
};
Expand Down

0 comments on commit 1fede7f

Please sign in to comment.