Is there a way to insert "middleware" to check socket responses? #4562
Unanswered
julianeden
asked this question in
Q&A
Replies: 1 comment 3 replies
-
No, there is currently nothing built-in for your use case. We might add it though, do you have a specific API in mind? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an extensive set of socket events for a browser game and I'm finding I need to individually try/catch all of the client's socket.emit callbacks for an expired/invalid session error response so I can show a "Please refresh login" type modal. Is there a better way to do this? I would love to be able to write something like~
socket.insertMiddleware('*', (response) => { if (response.error) { ... } });
I see the
socket.prependAny
option in the documentation, but it doesn't seem to give me a way to "stop the chain" - that is to say, if there's an error, I want to only execute the error handler and not fire the downstream happy path event listener. The documentation also says there is no error handling in socket.io, so should I infer that this is not possible?Beta Was this translation helpful? Give feedback.
All reactions