Skip to content

Elysia websockets and per-event handling #1024

Answered by dy0gu
MinskLeo asked this question in Q&A
Discussion options

You must be logged in to vote

Ah I see what you mean now but no, you can't create custom events on a WebSocket, this is not an Elysia thing it's just how WebSockets work.

The closest thing, and generally the accepted way to do what you want, is to use a message format like [eventname, data_object] then parse it in the message event and run your logic based on the event name.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@MinskLeo
Comment options

@dy0gu
Comment options

Answer selected by MinskLeo
@MinskLeo
Comment options

@bmakan
Comment options

@MinskLeo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants