diff --git a/packages/net/client/socket.js b/packages/net/client/socket.js index 8ea654e..bbfc8bc 100644 --- a/packages/net/client/socket.js +++ b/packages/net/client/socket.js @@ -61,10 +61,10 @@ export class SocketClient extends decorate(class {}) { const [, M] = entries[i]; const {default: Packet} = M; const id = idFrom(M); - this.socket.on(id, (data) => { + this.socket.on(id, (data, fn) => { const packet = new Packet(data); debug('recieved packet %o', packet); - this.emit('packet', packet); + this.emit('packet', packet, fn); }); } } @@ -77,11 +77,11 @@ export class SocketClient extends decorate(class {}) { return this.socket ? this.socket.id : undefined; } - send(packet) { + send(packet, fn) { debug('sending packet %o', packet); const {idFrom} = require('../packet/registrar'); const id = idFrom(packet.constructor); - this.socket.binary(true).emit(id, packet.data); + this.socket.binary(true).emit(id, packet.data, fn); } get session() { diff --git a/packages/net/server/socket.js b/packages/net/server/socket.js index cff4858..f58583b 100644 --- a/packages/net/server/socket.js +++ b/packages/net/server/socket.js @@ -68,10 +68,10 @@ class ServerSocket extends decorateSocket(class {}) { const [, M] = entries[i]; const {default: Packet} = M; const id = idFrom(M); - this.socket.on(id, (data) => { + this.socket.on(id, (data, fn) => { const packet = new Packet(data); debug('recieved packet %o', packet); - this.emit('packet', packet); + this.emit('packet', packet, fn); }); } this.socket.on('disconnect', (...args) => { @@ -95,11 +95,11 @@ class ServerSocket extends decorateSocket(class {}) { this.socket.join(channel); } - send(packet) { + send(packet, fn) { debug('sending packet %o', packet); const {idFrom} = require('../packet/registrar'); const id = idFrom(packet.constructor); - this.socket.binary(true).emit(id, packet.data); + this.socket.binary(true).emit(id, packet.data, fn); } get session() {