|
@@ -77,7 +77,7 @@ function Peer(id, options) {
|
|
// Initialize the 'socket' (which is actually a mix of XHR streaming and
|
|
// Initialize the 'socket' (which is actually a mix of XHR streaming and
|
|
// websockets.)
|
|
// websockets.)
|
|
var self = this;
|
|
var self = this;
|
|
- this.socket = new Socket(this.options.secure, this.options.host, this.options.port, this.options.key);
|
|
|
|
|
|
+ this.socket = new Socket(this.options.secure, this.options.host, this.options.port, this.options.path, this.options.key);
|
|
this.socket.on('message', function(data) {
|
|
this.socket.on('message', function(data) {
|
|
self._handleMessage(data);
|
|
self._handleMessage(data);
|
|
});
|
|
});
|
|
@@ -107,7 +107,7 @@ Peer.prototype._retrieveId = function(cb) {
|
|
var self = this;
|
|
var self = this;
|
|
var http = new XMLHttpRequest();
|
|
var http = new XMLHttpRequest();
|
|
var protocol = this.options.secure ? 'https://' : 'http://';
|
|
var protocol = this.options.secure ? 'https://' : 'http://';
|
|
- var url = protocol + this.options.host + ':' + this.options.port + '/' + this.options.key + '/id';
|
|
|
|
|
|
+ var url = protocol + this.options.host + ':' + this.options.port + '/' + this._fullPath() + this.options.key + '/id';
|
|
var queryString = '?ts=' + new Date().getTime() + '' + Math.random();
|
|
var queryString = '?ts=' + new Date().getTime() + '' + Math.random();
|
|
url += queryString;
|
|
url += queryString;
|
|
|
|
|
|
@@ -228,6 +228,10 @@ Peer.prototype._handleMessage = function(message) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Peer.prototype._fullPath = function() {
|
|
|
|
+ return this.options.path ? this.options.path + '/' : '';
|
|
|
|
+}
|
|
|
|
+
|
|
/** Stores messages without a set up connection, to be claimed later. */
|
|
/** Stores messages without a set up connection, to be claimed later. */
|
|
Peer.prototype._storeMessage = function(connectionId, message) {
|
|
Peer.prototype._storeMessage = function(connectionId, message) {
|
|
if (!this._lostMessages[connectionId]) {
|
|
if (!this._lostMessages[connectionId]) {
|