|
@@ -882,8 +882,13 @@ Peer.prototype._checkIn = function() {
|
|
if (!this._id) {
|
|
if (!this._id) {
|
|
try {
|
|
try {
|
|
var http = new XMLHttpRequest();
|
|
var http = new XMLHttpRequest();
|
|
|
|
+ var url = this._httpUrl + '/id';
|
|
|
|
+ console.log(this._apikey);
|
|
|
|
+ if (!!this._apikey)
|
|
|
|
+ url += '?key=' + this._apikey;
|
|
|
|
+
|
|
// If there's no ID we need to wait for one before trying to init socket.
|
|
// If there's no ID we need to wait for one before trying to init socket.
|
|
- http.open('get', this._httpUrl + '/id', true);
|
|
|
|
|
|
+ http.open('get', url, true);
|
|
http.onreadystatechange = function() {
|
|
http.onreadystatechange = function() {
|
|
if (!self._id && http.readyState > 2 && !!http.responseText) {
|
|
if (!self._id && http.readyState > 2 && !!http.responseText) {
|
|
try {
|
|
try {
|
|
@@ -922,7 +927,7 @@ Peer.prototype._startXhrStream = function() {
|
|
http.onreadystatechange = function() {
|
|
http.onreadystatechange = function() {
|
|
self._handleStream(http);
|
|
self._handleStream(http);
|
|
};
|
|
};
|
|
- http.send(JSON.stringify({ id: this._id }));
|
|
|
|
|
|
+ http.send(JSON.stringify({ id: this._id, key: this._apikey }));
|
|
} catch(e) {
|
|
} catch(e) {
|
|
util.log('XMLHttpRequest not available; defaulting to WebSockets');
|
|
util.log('XMLHttpRequest not available; defaulting to WebSockets');
|
|
}
|
|
}
|
|
@@ -960,8 +965,13 @@ Peer.prototype._socketInit = function() {
|
|
return;
|
|
return;
|
|
|
|
|
|
var wsurl = 'ws://' + this._server + '/ws';
|
|
var wsurl = 'ws://' + this._server + '/ws';
|
|
- if (!!this._id)
|
|
|
|
|
|
+ if (!!this._id) {
|
|
wsurl += '?id=' + this._id;
|
|
wsurl += '?id=' + this._id;
|
|
|
|
+ if (!!this._apikey)
|
|
|
|
+ wsurl += '&key=' + this._apikey;
|
|
|
|
+ } else if (!!this._apikey) {
|
|
|
|
+ wsurl += '?key=' + this._apikey;
|
|
|
|
+ }
|
|
this._socket = new WebSocket(wsurl);
|
|
this._socket = new WebSocket(wsurl);
|
|
|
|
|
|
var self = this;
|
|
var self = this;
|