feat: cheap channel API
This commit is contained in:
parent
8c876f7efb
commit
7e4e3e12ee
|
@ -67,11 +67,28 @@ export class SocketClient extends decorate(class {}) {
|
|||
this.socket.disconnect();
|
||||
}
|
||||
|
||||
get id() {
|
||||
return this.socket ? this.socket.id : undefined;
|
||||
}
|
||||
|
||||
send(packet) {
|
||||
const id = idFromPacket(packet.constructor);
|
||||
this.socket.binary(true).emit(id, packet.data);
|
||||
}
|
||||
|
||||
get session() {
|
||||
return this.socket.handshake.session;
|
||||
}
|
||||
|
||||
to(channel) {
|
||||
return {
|
||||
send: (packet) => {
|
||||
const id = idFromPacket(packet.constructor);
|
||||
this.socket.binary(true).to(channel).emit(id, packet.data);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
tryReconnect() {
|
||||
if (this.isReconnecting) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user