79 lines
1.8 KiB
JavaScript
79 lines
1.8 KiB
JavaScript
|
/**
|
||
|
* Raw Cast API object - should always correspond with the Cast Schema
|
||
|
* @param apiSocket
|
||
|
* @param castType
|
||
|
* @param source
|
||
|
* @param sourceProperties
|
||
|
* @constructor
|
||
|
*/
|
||
|
R3.API.Socket.Cast = function(
|
||
|
apiSocket,
|
||
|
castType,
|
||
|
source,
|
||
|
sourceProperties
|
||
|
) {
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(apiSocket)) {
|
||
|
apiSocket = {
|
||
|
socketType : R3.API.Socket.SOCKET_CAST
|
||
|
};
|
||
|
}
|
||
|
|
||
|
R3.API.Socket.call(
|
||
|
this,
|
||
|
apiSocket.id,
|
||
|
apiSocket.name,
|
||
|
apiSocket.socketType,
|
||
|
apiSocket.roomId,
|
||
|
apiSocket.peerId,
|
||
|
apiSocket.server,
|
||
|
apiSocket.parentEntity
|
||
|
);
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(castType)) {
|
||
|
castType = R3.API.Socket.Cast.CAST_TYPE_ROOM;
|
||
|
}
|
||
|
this.castType = castType;
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(source)) {
|
||
|
source = null;
|
||
|
}
|
||
|
this.source = source;
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(sourceProperties)) {
|
||
|
sourceProperties = null;
|
||
|
}
|
||
|
this.sourceProperties = sourceProperties;
|
||
|
|
||
|
R3.API.Component.call(
|
||
|
this,
|
||
|
R3.Component.SOCKET_CAST
|
||
|
);
|
||
|
};
|
||
|
|
||
|
R3.API.Socket.Cast.prototype = Object.create(R3.API.Socket.prototype);
|
||
|
R3.API.Socket.Cast.prototype.constructor = R3.API.Socket.Cast.Receive;
|
||
|
|
||
|
R3.API.Socket.Cast.CAST_TYPE_ROOM = 0x1;
|
||
|
R3.API.Socket.Cast.CAST_TYPE_PEER = 0x2;
|
||
|
R3.API.Socket.Cast.CAST_TYPE_ALL = 0x3;
|
||
|
R3.API.Socket.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Creates an API.Socket.Cast from an Object Cast
|
||
|
* @param objectSocketCast
|
||
|
* @constructor
|
||
|
*/
|
||
|
R3.API.Socket.Cast.FromObject = function(objectSocketCast) {
|
||
|
|
||
|
var apiSocket = R3.API.Socket.FromObject(objectSocketCast);
|
||
|
|
||
|
return new R3.API.Socket.Cast(
|
||
|
apiSocket,
|
||
|
objectSocketCast.castType,
|
||
|
objectSocketCast.source,
|
||
|
objectSocketCast.sourceProperties
|
||
|
);
|
||
|
};
|