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
{{ message }}
Repository navigation
Add example demonstrating a basic WebSocket protocol with message types #217
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 :)
changed the title [-]Example on how to consume socket connection type messages (like in HTML5 websocket or socket.io)[/-][+]Add example demonstrating a basic WebSocket protocol[/+]on Apr 14, 2020
changed the title [-]Add example demonstrating a basic WebSocket protocol[/-][+]Add example demonstrating a basic WebSocket protocol with different requests[/+]on Apr 14, 2020
changed the title [-]Add example demonstrating a basic WebSocket protocol with different requests[/-][+]Add example demonstrating a basic WebSocket protocol with message types[/+]on Apr 14, 2020
So I created this fork with the chat example upgraded for specific chat rooms.
In total, it has 4 endpoints
/subscribe - Subscribe to all messages sent to the websocket server
/subscribe/ - Subscribe to all messages from a specific room (i.e. /subscribe/cool)
/publish - Publish to every single listener regardless of whether they are in a room or not
/publish/ - Publish to your room and any global subscribers (i.e publish/cool)
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.
Activity
nhooyr commentedon Mar 27, 2020
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.
kabaluyot commentedon Mar 27, 2020
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 :)
nhooyr commentedon Mar 27, 2020
I understand, let's add a simple example showing how to route different messages.
kabaluyot commentedon Mar 27, 2020
Thank you sir. Maybe you can send just a guide or sample here and I will make a PR
[-]Example on how to consume socket connection type messages (like in HTML5 websocket or socket.io)[/-][+]Add example demonstrating a basic WebSocket protocol[/+][-]Add example demonstrating a basic WebSocket protocol[/-][+]Add example demonstrating a basic WebSocket protocol with different requests[/+][-]Add example demonstrating a basic WebSocket protocol with different requests[/-][+]Add example demonstrating a basic WebSocket protocol with message types[/+]pymq commentedon Apr 14, 2020
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.
kabaluyot commentedon Apr 15, 2020
Thank you @pymq, will definitely check it out. For the moment, I was forced to do the client implementation using Typescript :/
dafinley commentedon May 17, 2020
So I created this fork with the chat example upgraded for specific chat rooms.
In total, it has 4 endpoints
/subscribe - Subscribe to all messages sent to the websocket server
/subscribe/ - Subscribe to all messages from a specific room (i.e. /subscribe/cool)
/publish - Publish to every single listener regardless of whether they are in a room or not
/publish/ - Publish to your room and any global subscribers (i.e publish/cool)
https://github.com/dafinley/websocket/tree/master/examples/chat
dafinley commentedon May 18, 2020
There's an ios and android app setup to work with it:
https://github.com/dafinley/twilio-video-app-android
https://github.com/dafinley/twilio-video-app-ios
kabaluyot commentedon May 18, 2020
Well appreciated @dafinley . Thank you
nhooyr commentedon May 19, 2020
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.
dafinley commentedon May 19, 2020
@nhooyr smooth websocket lib man. This was my intro into
go. If anybody lands here I did a walkthru video on using this chat example https://www.youtube.com/watch?v=Jhnv5tA6Wawnhooyr commentedon Aug 6, 2021
See #309 and #301 for more problems the new example should fix.