/** * Creates a Server object * @param apiServer GameLib.API.Server * @constructor */ GameLib.Server = function( apiServer ) { if (GameLib.Utils.UndefinedOrNull(apiServer)) { apiServer = {}; } GameLib.API.Server.call( this, apiServer.id, apiServer.name, apiServer.protocol, apiServer.ip, apiServer.port, apiServer.protocols, apiServer.parentEntity ); this.connected = false; GameLib.Component.call(this); }; GameLib.Server.prototype = Object.create(GameLib.Component.prototype); GameLib.Server.prototype.constructor = GameLib.Server; GameLib.Server.prototype.createInstance = function() { this.instance = true; GameLib.Component.prototype.createInstance.call(this); }; /** * Updates the instance with the current state */ GameLib.Server.prototype.updateInstance = function(property) { if (property === 'protocol') { console.log('todo: server protocol update'); } if (property === 'ip') { console.log('todo: server ip update'); } if (property === 'port') { console.log('todo: server port update'); } if (property === 'protocols') { console.log('todo: server protocols update'); } }; /** * Converts a GameLib.Server to a new GameLib.API.Server * @returns {GameLib.API.Server} */ GameLib.Server.prototype.toApiObject = function() { return new GameLib.API.Server( this.id, this.name, this.protocol, this.ip, this.port, this.protocols, GameLib.Utils.IdOrNull(this.parentEntity) ); }; /** * Converts from an Object Server to a GameLib.Server * @param objectServer Object * @returns {GameLib.Server} * @constructor */ GameLib.Server.FromObject = function(objectServer) { var apiServer = GameLib.API.Server.FromObject(objectServer); return new GameLib.Server(apiServer); };