websocket
parent
64557daad3
commit
16f21ebcc8
|
@ -30,7 +30,7 @@ R3.API.Server = function(
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (R3.Utils.UndefinedOrNull(protocol)) {
|
if (R3.Utils.UndefinedOrNull(protocol)) {
|
||||||
protocol = 'http';
|
protocol = R3.API.Server.PROTOCOL_HTTP_SSL;
|
||||||
}
|
}
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ R3.API.Server = function(
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
|
||||||
if (R3.Utils.UndefinedOrNull(port)) {
|
if (R3.Utils.UndefinedOrNull(port)) {
|
||||||
port = 80;
|
port = R3.API.Server.PORT_SECURE;
|
||||||
}
|
}
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
|
||||||
|
@ -59,21 +59,14 @@ R3.API.Server = function(
|
||||||
R3.API.Server.prototype = Object.create(R3.API.Component.prototype);
|
R3.API.Server.prototype = Object.create(R3.API.Component.prototype);
|
||||||
R3.API.Server.prototype.constructor = R3.API.Server;
|
R3.API.Server.prototype.constructor = R3.API.Server;
|
||||||
|
|
||||||
/**
|
R3.API.Server.PROTOCOL_HTTP = 'http';
|
||||||
* Creates an API Server from an Object Server
|
R3.API.Server.PROTOCOL_HTTP_SSL = 'https';
|
||||||
* @param objectServer
|
R3.API.Server.PROTOCOL_WEBSOCKET = 'ws';
|
||||||
* @constructor
|
R3.API.Server.PROTOCOL_WEBSOCKET_SSL = 'wss';
|
||||||
*/
|
|
||||||
R3.API.Server.FromObject = function(objectServer) {
|
|
||||||
|
|
||||||
return new R3.API.Server(
|
R3.API.Server.PORT_INSECURE = 80;
|
||||||
objectServer.id,
|
R3.API.Server.PORT_SECURE = 443;
|
||||||
objectServer.name,
|
|
||||||
objectServer.protocol,
|
|
||||||
objectServer.ip,
|
|
||||||
objectServer.port,
|
|
||||||
objectServer.protocols,
|
|
||||||
objectServer.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
R3.API.Server.prototype.getURL = function() {
|
||||||
|
return this.protocol + '://' + this.ip + ':' + this.port;
|
||||||
|
};
|
|
@ -45,7 +45,11 @@ R3.API.Socket = function(
|
||||||
this.peerId = peerId;
|
this.peerId = peerId;
|
||||||
|
|
||||||
if (R3.Utils.UndefinedOrNull(server)) {
|
if (R3.Utils.UndefinedOrNull(server)) {
|
||||||
server = null;
|
server = new R3.API.Server(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
R3.API.Server.PROTOCOL_WEBSOCKET_SSL
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Creates a Socket object
|
* Creates a Socket object
|
||||||
* @param socket R3.Socket
|
* @param socket R3.Socket
|
||||||
* @param apiSocket R3.API.Socket
|
* @param apiSocket R3.API.Socket
|
||||||
|
* @property socketType
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
R3.Socket = function(
|
R3.Socket = function(
|
||||||
|
@ -57,7 +58,7 @@ R3.Socket.prototype.constructor = R3.Socket;
|
||||||
|
|
||||||
R3.Socket.prototype.createInstance = function() {
|
R3.Socket.prototype.createInstance = function() {
|
||||||
|
|
||||||
this.instance = true;
|
this.instance = new WebSocket(this.server.getURL());
|
||||||
|
|
||||||
R3.Component.prototype.createInstance.call(this);
|
R3.Component.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
@ -66,18 +67,23 @@ R3.Socket.prototype.createInstance = function() {
|
||||||
* Updates the instance with the current state
|
* Updates the instance with the current state
|
||||||
*/
|
*/
|
||||||
R3.Socket.prototype.updateInstance = function(property) {
|
R3.Socket.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (property === 'socketType') {
|
if (property === 'socketType') {
|
||||||
console.log('todo: implement socket socketType update');
|
console.log('todo: implement socket socketType update');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'roomId') {
|
if (property === 'roomId') {
|
||||||
console.log('todo: implement socket roomId update');
|
console.log('todo: implement socket roomId update');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'peerId') {
|
if (property === 'peerId') {
|
||||||
console.log('todo: implement socket peerId update');
|
console.log('todo: implement socket peerId update');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'server') {
|
if (property === 'server') {
|
||||||
console.log('todo: implement socket server update');
|
console.log('todo: implement socket server update');
|
||||||
}
|
}
|
||||||
|
|
||||||
R3.D3.Texture.prototype.updateInstance.call(this, property);
|
R3.D3.Texture.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,7 +92,6 @@ R3.Socket.prototype.updateInstance = function(property) {
|
||||||
* @returns {R3.API.Socket}
|
* @returns {R3.API.Socket}
|
||||||
*/
|
*/
|
||||||
R3.Socket.prototype.toApiObject = function() {
|
R3.Socket.prototype.toApiObject = function() {
|
||||||
|
|
||||||
return new R3.API.Socket(
|
return new R3.API.Socket(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
|
@ -96,20 +101,4 @@ R3.Socket.prototype.toApiObject = function() {
|
||||||
R3.Utils.IdOrNull(this.server),
|
R3.Utils.IdOrNull(this.server),
|
||||||
R3.Utils.IdOrNull(this.parentEntity)
|
R3.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts from an Object Socket to a R3.Socket
|
|
||||||
* @param sockets R3.SocketsRuntime
|
|
||||||
* @param objectSocket Object
|
|
||||||
* @returns {R3.Socket}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
R3.Socket.FromObject = function(sockets, objectSocket) {
|
|
||||||
var apiSocket = R3.API.Socket.FromObject(objectSocket);
|
|
||||||
return new R3.Socket(
|
|
||||||
sockets,
|
|
||||||
apiSocket
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,18 +102,3 @@ R3.Socket.Cast.prototype.toApiObject = function() {
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts from an Object Cast to a R3.Socket.Cast
|
|
||||||
* @param sockets R3.SocketsRuntime
|
|
||||||
* @param objectCast Object
|
|
||||||
* @returns {R3.Socket.Cast}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
R3.Socket.Cast.FromObject = function(sockets, objectCast) {
|
|
||||||
var apiCast = R3.API.Socket.Cast.FromObject(objectCast);
|
|
||||||
return new R3.Socket.Cast(
|
|
||||||
sockets,
|
|
||||||
apiCast
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue