|
@@ -4,17 +4,16 @@ function Peer(options) {
|
|
|
|
|
|
options = util.extend({
|
|
|
debug: false,
|
|
|
- host: 'localhost',
|
|
|
+ host: '0.peerjs.com',
|
|
|
config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] },
|
|
|
port: 80
|
|
|
}, options);
|
|
|
- this.options = options;
|
|
|
+ this._options = options;
|
|
|
util.debug = options.debug;
|
|
|
|
|
|
// TODO: default should be the cloud server.
|
|
|
this._server = options.host + ':' + options.port;
|
|
|
this._httpUrl = 'http://' + this._server;
|
|
|
- this._config = options.config;
|
|
|
|
|
|
// Ensure alphanumeric_-
|
|
|
if (options.id && !/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(options.id))
|
|
@@ -190,7 +189,7 @@ Peer.prototype._handleServerMessage = function(message) {
|
|
|
metadata: message.metadata,
|
|
|
sdp: message.sdp,
|
|
|
socketOpen: this._socketOpen,
|
|
|
- config: this._config
|
|
|
+ config: this._options.config
|
|
|
};
|
|
|
var self = this;
|
|
|
var connection = new DataConnection(this._id, peer, this._socket, this._httpUrl, function(err, connection) {
|
|
@@ -266,7 +265,7 @@ Peer.prototype.connect = function(peer, metadata, cb) {
|
|
|
var options = {
|
|
|
metadata: metadata,
|
|
|
socketOpen: this._socketOpen,
|
|
|
- config: this._config
|
|
|
+ config: this._options.config
|
|
|
};
|
|
|
var connection = new DataConnection(this._id, peer, this._socket, this._httpUrl, cb, options);
|
|
|
this._attachConnectionListeners(connection);
|