I want to use Fleck for my WebSocket project,
Server side looks pretty straightforward, but how to I differentiate opened connections. is there some sort of ID? The only way I can think of is to create GUID in OnOpen event and pass it back to client. is there a smarter solution?
Basic server set up:
socket.OnOpen = () =>
{
Console.WriteLine("Open!");
allSockets.Add(socket);
};
socket.OnClose = () =>
{
Console.WriteLine("Close!");
allSockets.Remove(socket);
};
socket.OnMessage = message =>
{
Console.WriteLine(message);
allSockets.ToList().ForEach(s => s.Send("Echo: " + message));
};
E.G. how would I make a chat room so all connection receive message except for the one sending.
Fleck server here: https://github.com/statianzo/Fleck
Fleck now creates a Guid Id on the WebSocketConnectionInfo for every connected client. This will help in cases where multiple connections are using the same IP. See the related commit here:
https://github.com/statianzo/Fleck/commit/fc037f49362bb41a2bc753a5ff51cc9da40ad824