Closed db2crush closed 5 years ago
Please, provide a minimal repository which reproduces your issue.
Thank you! I tested this and you're right. Nonetheless, I'm afraid that this issue can rather come from the underlying socket.io
library. Also, regardless of the issue, I'm not sure if that is a good idea to create 2 different gateways under 1 namespace + subscribe to exact same messages from within them. You basically can never be sure which method will be evaluated first (because it depends on modules hierarchy)
thx for fast reply.
how you think about if the event name is different? ex) ‘ABC’ and ‘ABCD’ events on test repo.
These work well when String is used for namespace value.. aka namespace: ‘group’. not regExp
This is due to the collision between UserGateway
and RoomGateway
. Basically, UserGateway
overrides subscribers defined in the RoomGateway
. Once you remove UserGateway
, your ABCD
event will be handled properly.
Is it the intent of nestjs that the gateway is not part of the module architecture? Http request can receive messages separated by a controller and I thought it was a modular architecture. I wanted to separate the events. I guess I know the intentions of nestjs anyway.
thx for nice lib :)
one more question,
I have tried to do a namespace dynamic binding with a single gateway, but @.Websocketserver decorator is not dynamic binding to namespace. Is this right?
And.. Should be the @Websocketserver decorator interface be a socketio { namespace }? The { Server } in Socket.io was grabbed as a decorator's interface in example, but the actual output is a some namespace of Socket.io...
And.. Should be the @Websocketserver decorator interface be a socketio { namespace }? The { Server } in Socket.io was grabbed as a decorator's interface in example, but the actual output is a some namespace of Socket.io...
see my answer here https://github.com/nestjs/nest/pull/1981
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm submitting a...
Current behavior
dynamic WebSocketGateway can not receive message. I set two modules, user and room. Then, web-client send socketio message to namespace /group then only first module in array of modules in app (in this case, UserModule) can receive message. the function fn(data){} in UserGateway receive message only.
When the interface value of WebSocketGateway is string, it works well. but RegExp, it is not work. namespace?: string | RegExp;
user.gateway.ts @.WebSocketGateway({ namespace: /group/, }) @.SubscribeMessage('ABC') fn(data) {} export class UserGateway {}
user.module.ts @.Module({ providers: [UserGateway], }) export class UserModule {}
room.gateway.ts @.WebSocketGateway({ namespace: /group/, }) @.SubscribeMessage('ABC') fn(data) {} export class RoomGateway {}
room.module.ts @.Module({ providers: [RoomGateway], }) export class RoomModule {}
app.module.ts @.Module({ imports: [UserModule, RoomModule], controllers: [AppController], providers: [AppService], }) export class AppModule {}
const socket = io('/group') socket.emit('ABC', {} , function(res){})
Expected behavior
dynamic WebSocketGateway can receive message. All gateways of modules in app module array can receive message.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment