diff --git a/src/game-lib-api-socket-cast.js b/src/game-lib-api-socket-cast.js index 385c71e..aa6f81e 100644 --- a/src/game-lib-api-socket-cast.js +++ b/src/game-lib-api-socket-cast.js @@ -43,7 +43,7 @@ GameLib.API.Socket.Cast = function( ); }; -GameLib.API.Socket.Cast.prototype = Object.create(GameLib.Component.prototype); +GameLib.API.Socket.Cast.prototype = Object.create(GameLib.API.Socket.prototype); GameLib.API.Socket.Cast.prototype.constructor = GameLib.API.Socket.Cast.Receive; GameLib.API.Socket.Cast.CAST_TYPE_ROOM = 0x1; diff --git a/src/game-lib-api-socket-receive.js b/src/game-lib-api-socket-receive.js index fc866b2..b376d6c 100644 --- a/src/game-lib-api-socket-receive.js +++ b/src/game-lib-api-socket-receive.js @@ -43,13 +43,12 @@ GameLib.API.Socket.Receive = function( ); }; -GameLib.API.Socket.Receive.prototype = Object.create(GameLib.Component.prototype); +GameLib.API.Socket.Receive.prototype = Object.create(GameLib.API.Socket.prototype); GameLib.API.Socket.Receive.prototype.constructor = GameLib.API.Socket.Receive; GameLib.API.Socket.Receive.RECEIVE_TYPE_ROOM = 0x1; GameLib.API.Socket.Receive.RECEIVE_TYPE_PEER = 0x2; - /** * Creates an API Socket.Receive from an Object Socket.Receive * @param socket GameLib.SocketsRuntime diff --git a/src/game-lib-socket-0.js b/src/game-lib-socket-0.js index 14c163f..1e28cca 100644 --- a/src/game-lib-socket-0.js +++ b/src/game-lib-socket-0.js @@ -37,11 +37,21 @@ GameLib.Socket = function( this.connected = false; + var linkedObjects = { + server : GameLib.Server + }; + + if (this.socketType === GameLib.API.Socket.TYPE_CAST) { + linkedObjects.source = GameLib.Component; + } + + if (this.socketType === GameLib.API.Socket.TYPE_RECEIVE) { + linkedObjects.destination = GameLib.Component; + } + GameLib.Component.call( this, - { - server : GameLib.Server - } + linkedObjects ); }; diff --git a/src/game-lib-socket-cast.js b/src/game-lib-socket-cast.js index 37ddb07..43f6aa5 100644 --- a/src/game-lib-socket-cast.js +++ b/src/game-lib-socket-cast.js @@ -18,10 +18,6 @@ GameLib.Socket.Cast = function( }; } - if (apiSocketCast instanceof GameLib.Socket.Cast) { - return apiSocketCast; - } - GameLib.API.Socket.Cast.call( this, apiSocketCast, @@ -35,16 +31,9 @@ GameLib.Socket.Cast = function( socket, apiSocketCast ); - - GameLib.Component.call( - this, - { - source : GameLib.Component - } - ); }; -GameLib.Socket.Cast.prototype = Object.create(GameLib.API.Socket.Cast.prototype); +GameLib.Socket.Cast.prototype = Object.create(GameLib.Socket.prototype); GameLib.Socket.Cast.prototype.constructor = GameLib.Socket.Cast; GameLib.Socket.Cast.prototype.createInstance = function() { diff --git a/src/game-lib-socket-receive.js b/src/game-lib-socket-receive.js index 8904a61..c0fc5a9 100644 --- a/src/game-lib-socket-receive.js +++ b/src/game-lib-socket-receive.js @@ -18,10 +18,6 @@ GameLib.Socket.Receive = function( }; } - if (apiSocketReceive instanceof GameLib.Socket.Receive) { - return apiSocketReceive; - } - GameLib.API.Socket.Receive.call( this, apiSocketReceive, @@ -36,16 +32,9 @@ GameLib.Socket.Receive = function( apiSocketReceive ); - GameLib.Component.call( - this, - { - destination : GameLib.Component - } - ); - }; -GameLib.Socket.Receive.prototype = Object.create(GameLib.API.Socket.Receive.prototype); +GameLib.Socket.Receive.prototype = Object.create(GameLib.Socket.prototype); GameLib.Socket.Receive.prototype.constructor = GameLib.Socket.Receive; GameLib.Socket.Receive.prototype.createInstance = function() {