HTML and CSS Reference
Connecting to the web server
The WebSocket server works in a similar way to the WebSocket clients. It responds
to events and performs actions when necessary.Regardless of the programming lan-
guage you use, every WebSocket server performs some specific actions. It is initial-
ized to a WebSocket address, it handles OnOpen , OnClose and OnMessage events,
and sends messages to the clients, too.
Creating the WebSocket server instance
Every WebSocket server needs a valid host and port. Here is how we create a We-
bSocketServer instance in Fleck:
var server = new
You can type any valid URL you'd like and specify a port that is not in use.
It is very useful to keep a record of the connected clients, as you may need to provide
them with different data or send different messages to each one.
Fleck represents the incoming connections (clients) with the IWebSocketConnec-
tion interface. We can create an empty list and update it whenever someone con-
nects or disconnects from our service:
var clients = new List<IWebSocketConnection>();
After that, we can call the Start method and wait for the clients to connect. When
started, the server is able to accept incoming connections.
In Fleck, the Start method needs a parameter which indicates the socket that raised