-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example demonstrating a basic WebSocket protocol with message types #217
Comments
This library provides no way to route messages, you'd have to do that yourself. You could via a map, a switch statement etc. See the examples for how to read and write messages. |
the chat example sir? If you may sir, can you provide a basic example for websocket client with "StockTicker" and "Stock" as channels (rooms). The examples are quite confusing esp to beginners and coming from different language like me :) |
I understand, let's add a simple example showing how to route different messages. |
Thank you sir. Maybe you can send just a guide or sample here and I will make a PR |
Hey @kabaluyot We had the same problem, so we ended up with writing simple socket.io alternative isp-etp-go on top of nhooyr/websocket, maybe you'd be interested. |
Thank you @pymq, will definitely check it out. For the moment, I was forced to do the client implementation using Typescript :/ |
So I created this fork with the chat example upgraded for specific chat rooms. /subscribe - Subscribe to all messages sent to the websocket server /publish - Publish to every single listener regardless of whether they are in a room or not https://github.com/dafinley/websocket/tree/master/examples/chat |
There's an ios and android app setup to work with it: |
Well appreciated @dafinley . Thank you |
With inspiration from @dafinley I think the best move here is to extend the chat example to add structure like timestamps to each message and add two more message types to indicate when a client connects/leaves. |
@nhooyr smooth websocket lib man. This was my intro into |
In HTML5 websockt or socket.io, you can consume messages just with the following lines of code:
How to achieve the example above in this library?
The text was updated successfully, but these errors were encountered: