58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
/**
|
|
* R3.API.Socket
|
|
* @param apiComponent
|
|
* @property roomId
|
|
* @property peerId
|
|
* @property server
|
|
* @constructor
|
|
*/
|
|
R3.API.Socket = function(
|
|
apiComponent
|
|
) {
|
|
|
|
__API_COMPONENT__;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.roomId)) {
|
|
apiComponent.roomId = 'room_' + R3.Utils.RandomId();
|
|
}
|
|
this.roomId = apiComponent.roomId;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.peerId)) {
|
|
apiComponent.peerId = null;
|
|
}
|
|
this.peerId = apiComponent.peerId;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.server)) {
|
|
R3.Event.Emit(
|
|
R3.Event.GET_WEBSOCKET_CONFIG,
|
|
'hello',
|
|
function(websocketConfig) {
|
|
if (websocketConfig) {
|
|
apiComponent.server = new R3.API.Server(
|
|
{
|
|
parent : this,
|
|
protocol : websocketConfig.protocol,
|
|
context : websocketConfig.context,
|
|
application : websocketConfig.application,
|
|
domain : websocketConfig.domain
|
|
}
|
|
);
|
|
} else {
|
|
apiComponent.server = new R3.API.Server(
|
|
{
|
|
parent : this,
|
|
protocol : R3.API.Server.PROTOCOL_WEBSOCKET_SSL
|
|
}
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
}
|
|
this.server = apiComponent.server;
|
|
|
|
};
|
|
|
|
R3.API.Socket.prototype = Object.create(R3.API.Component.prototype);
|
|
R3.API.Socket.prototype.constructor = R3.API.Socket;
|