diff --git a/packages/socket/src/client/socket.js b/packages/socket/src/client/socket.js index 1aca4aa..60e1875 100644 --- a/packages/socket/src/client/socket.js +++ b/packages/socket/src/client/socket.js @@ -94,22 +94,22 @@ export default class SocketClient extends decorate(Class) { return this.socket ? this.socket.id : undefined; } - static send(latus, socket, packetOrDehydrated) { + static send(latus, socket, packetOrDehydrated, method) { const packet = Array.isArray(packetOrDehydrated) ? this.hydrate(latus, packetOrDehydrated) : packetOrDehydrated; debug('sending packet %o', packet); const {id} = packet.constructor; - return socket.emitPromise(id, packet.data); + return socket[method](id, packet.data); } send(packet) { - return this.constructor.send(this.latus, this.socket, packet); + return this.constructor.send(this.latus, this.socket, packet, 'emitPromise'); } to(room) { return { - send: (packet) => this.constructor.send(this.latus, this.socket.to(room), packet), + send: (packet) => this.constructor.send(this.latus, this.socket.to(room), packet, 'emit'), }; } diff --git a/packages/socket/src/socket.js b/packages/socket/src/socket.js index 4795529..19fadb9 100644 --- a/packages/socket/src/socket.js +++ b/packages/socket/src/socket.js @@ -72,22 +72,22 @@ export default class ServerSocket extends decorate(Class) { return this.socket.rooms; } - static send(latus, socket, packetOrDehydrated) { + static send(latus, socket, packetOrDehydrated, method) { const packet = Array.isArray(packetOrDehydrated) ? this.hydrate(latus, packetOrDehydrated) : packetOrDehydrated; debug('sending packet %s(%o)', packet.constructor.name, packet.data); const {id} = packet.constructor; - return socket.emitPromise(id, packet.data); + return socket[method](id, packet.data); } send(packet) { - return this.constructor.send(this.latus, this.socket, packet); + return this.constructor.send(this.latus, this.socket, packet, 'emitPromise'); } to(room) { return { - send: (packet) => this.constructor.send(this.latus, this.socket.to(room), packet), + send: (packet) => this.constructor.send(this.latus, this.socket.to(room), packet, 'emit'), }; }