From ee90adc22eb07befbeb4f7fd4c6481991f7d1140 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sat, 30 Dec 2017 11:20:00 +0100 Subject: [PATCH 1/2] extend from API socket --- src/game-lib-api-socket-cast.js | 2 +- src/game-lib-api-socket-receive.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 From 42132fd2df41c41106d9a02477daa9e6f8de1f8e Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sat, 30 Dec 2017 11:42:31 +0100 Subject: [PATCH 2/2] fix constructor call process --- src/game-lib-socket-0.js | 16 +++++++++++++--- src/game-lib-socket-cast.js | 7 ------- src/game-lib-socket-receive.js | 7 ------- 3 files changed, 13 insertions(+), 17 deletions(-) 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..1452aaa 100644 --- a/src/game-lib-socket-cast.js +++ b/src/game-lib-socket-cast.js @@ -35,13 +35,6 @@ GameLib.Socket.Cast = function( socket, apiSocketCast ); - - GameLib.Component.call( - this, - { - source : GameLib.Component - } - ); }; GameLib.Socket.Cast.prototype = Object.create(GameLib.API.Socket.Cast.prototype); diff --git a/src/game-lib-socket-receive.js b/src/game-lib-socket-receive.js index 8904a61..d8b6b51 100644 --- a/src/game-lib-socket-receive.js +++ b/src/game-lib-socket-receive.js @@ -36,13 +36,6 @@ GameLib.Socket.Receive = function( apiSocketReceive ); - GameLib.Component.call( - this, - { - destination : GameLib.Component - } - ); - }; GameLib.Socket.Receive.prototype = Object.create(GameLib.API.Socket.Receive.prototype);