HTML and CSS Reference
In-Depth Information
server.Start(socket) =>
{
});
Some syntax explanation: what follows the Start declaration is called a C# Action
and you can totally ignore it if you're using a different language. We'll handle all of
the events inside the Start block.
Open
The OnOpen event determines that a new client has requested access and performs
the initial handshake. We should add the client to the list and probably store any in-
formation related to it, such as the IP address. Fleck provides us with such informa-
tion, as well as a unique identifier for the connection.
server.Start(socket) =>
{
socket.OnOpen = () =>
{
// Add the incoming connection to our list.
clients.Add(socket);
}
// Handle the other events hereā€¦
});
Close
The OnClose event is raised whenever a client is disconnected. We can remove
that client from our list and inform the rest of the clients about the disconnection:
socket.OnClose = () =>
{
// Remove the disconnected client from the
list.
Search WWH ::




Custom Search