Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void OnDisconnect(UserContext context)
- {
- Console.WriteLine("Client Disconnected : " + context.ClientAddress);
- var user = OnlineUsers.Keys.Where(o => o.Context.ClientAddress == context.ClientAddress).Single(); // exception here because collection does dot contain the element
- string trash; // Concurrent dictionaries make things weird
- OnlineUsers.TryRemove(user, out trash);
- if (!String.IsNullOrEmpty(user.Name))
- {
- var r = new Response {Type = ResponseType.Disconnect, Data = new {user.Name}};
- Broadcast(JsonConvert.SerializeObject(r));
- }
- BroadcastNameList();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement