Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The WebSocket API is Event-Driven, meaning that you implement in your code event handlers, which are called when the corresponding events are triggered.
You do that by creating a Listener Component API which implements any of the event handlers, and then you register that Listener Component with the WebSocket endpoint by using the WebsocketRegister() function.
Many of the event handlers receive a WebSocket object as an argument, which allows you to interact with the remote connection on a low level, or retrieve information or references to other useful objects.
One of those useful objects is the ConnectionManager, which keeps track of the active connections, and lets you broadcast messages to different channels.