88 lines
1.7 KiB
JavaScript
88 lines
1.7 KiB
JavaScript
/**
|
|
* Raw Cast API object - should always correspond with the Cast Schema
|
|
* @param id
|
|
* @param name
|
|
* @param castType
|
|
* @param roomId
|
|
* @param peer
|
|
* @param serverIp
|
|
* @param port
|
|
* @param parentEntity
|
|
* @constructor
|
|
*/
|
|
GameLib.API.Cast = function(
|
|
id,
|
|
name,
|
|
castType,
|
|
roomId,
|
|
peer,
|
|
serverIp,
|
|
port,
|
|
parentEntity
|
|
) {
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
id = GameLib.Utils.RandomId();
|
|
}
|
|
this.id = id;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
name = 'Cast (' + this.id + ')';
|
|
}
|
|
this.name = name;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(castType)) {
|
|
castType = GameLib.Cast.CAST_TYPE_ROOM;
|
|
}
|
|
this.castType = castType;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(roomId)) {
|
|
roomId = 'default';
|
|
}
|
|
this.roomId = roomId;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(peer)) {
|
|
peer = null;
|
|
}
|
|
this.peer = peer;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(serverIp)) {
|
|
serverIp = '127.0.0.1';
|
|
}
|
|
this.serverIp = serverIp;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(port)) {
|
|
port = 80;
|
|
}
|
|
this.port = port;
|
|
|
|
GameLib.API.Component.call(
|
|
this,
|
|
GameLib.Component.CAST,
|
|
parentEntity
|
|
);
|
|
};
|
|
|
|
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);
|
|
GameLib.API.Cast.prototype.constructor = GameLib.API.Cast;
|
|
|
|
/**
|
|
* Creates an API Cast from an Object Cast
|
|
* @param objectCast
|
|
* @constructor
|
|
*/
|
|
GameLib.API.Cast.FromObject = function(objectCast) {
|
|
|
|
return new GameLib.API.Cast(
|
|
objectCast.id,
|
|
objectCast.name,
|
|
objectCast.castType,
|
|
objectCast.roomId,
|
|
objectCast.peer,
|
|
objectCast.serverIp,
|
|
objectCast.port,
|
|
objectCast.parentEntity
|
|
);
|
|
|
|
};
|