Advertisement
Guest User

Untitled

a guest
Jun 14th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1.  
  2.         public static void OnDisconnect(UserContext context)
  3.         {
  4.             Console.WriteLine("Client Disconnected : " + context.ClientAddress);
  5.             var user = OnlineUsers.Keys.Where(o => o.Context.ClientAddress == context.ClientAddress).Single(); // exception here because collection does dot contain the element
  6.  
  7.             string trash; // Concurrent dictionaries make things weird
  8.  
  9.             OnlineUsers.TryRemove(user, out trash);
  10.  
  11.             if (!String.IsNullOrEmpty(user.Name))
  12.             {
  13.                 var r = new Response {Type = ResponseType.Disconnect, Data = new {user.Name}};
  14.  
  15.                 Broadcast(JsonConvert.SerializeObject(r));
  16.             }
  17.  
  18.             BroadcastNameList();
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement