admin管理员组文章数量:1366075
I created two socket.io namespaces because there is an agent and customer in chat application and their handleConnection, handleDisconnect functions and etc. are different. That is why I separated them instead of writing if-else blocks to differentiate who connects. So now the issue occurs: I can not add them to the same room, because room is bounded to the namespace which is created in. Is there any way to do so? Or separating them is not even correct? I tried to implement this and this to test, but they did not work either even there is of
function in Server
class.
TypeError: this.server.of is not a function at CustomerGateway.handleConnection
@WebSocketGateway({ cors: { origin: '*' }, namespace: '/customer' })
export class CustomerGateway implements OnGatewayConnection, OnGatewayDisconnect {
constructor(private readonly chatService: ChatService) {}
@WebSocketServer() server: Server;
async handleConnection(client: Socket) {
console.log(`Connected customer: ${client.id}`);
console.log(this.server.of('/customer'));
const key = '';
const room = `room:${key}`;
client.join(room);
}
本文标签: typescriptHow to add different namespace clients to the same roomStack Overflow
版权声明:本文标题:typescript - How to add different namespace clients to the same room? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743774166a2536663.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论