You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using socket.io v4.0 custom adapter with nestjs and I see that the implementation in nestjs v8.0.0 will support socket.io v4.
One issue that I've had was my exception handlers had no way to get the actual event name from the socket itself or the data, which I would like to emit the error back to: .on(event_name) as opposed to a general error handler .on("ERROR").
It seemed of value to me to emit the error within the context of the event. In order to achieve this without forcing the client-side to send the event name as a data parameter OR scoping my validation pipes & errors to each request, I edited the socket.io adapter bindMessageHandlers as follows:
The end result is, everytime I use the host to switchToWs().getData() -- I will also have the event_name property defined.
I thought about making a pull request to contribute this bit to the adapter in version 8.0.0 but I wanted to ask for some feedback on the use case itself and -- most importantly --- what would be the best case to propagate that configuration all the way down to the bindMessageHandlers in the adapter, as currently there's no constructor that accepts any kind of options there.
The text was updated successfully, but these errors were encountered:
I'm currently using socket.io v4.0 custom adapter with nestjs and I see that the implementation in nestjs v8.0.0 will support socket.io v4.
One issue that I've had was my exception handlers had no way to get the actual event name from the socket itself or the data, which I would like to emit the error back to: .on(event_name) as opposed to a general error handler .on("ERROR").
It seemed of value to me to emit the error within the context of the event. In order to achieve this without forcing the client-side to send the event name as a data parameter OR scoping my validation pipes & errors to each request, I edited the socket.io adapter bindMessageHandlers as follows:
then the mapPayload consumes it as such:
The end result is, everytime I use the host to switchToWs().getData() -- I will also have the event_name property defined.
I thought about making a pull request to contribute this bit to the adapter in version 8.0.0 but I wanted to ask for some feedback on the use case itself and -- most importantly --- what would be the best case to propagate that configuration all the way down to the bindMessageHandlers in the adapter, as currently there's no constructor that accepts any kind of options there.
The text was updated successfully, but these errors were encountered: