public static void OnServerClose(this RoomServer roomServer, DuelServer server) { using (PacketWriter writer = new PacketWriter(2)) { writer.Write((byte)RoomMessage.ServerClose); writer.Write(server.Port); DuelServer srv = roomServer.GetMinServer(); lock (srv.AsyncLock) { srv.Count = 0; } if (srv != null) { //Special handling writer.Write(srv.Port); writer.Write(srv.NeedAuth); //session.ServerInfo = srv; lock (roomServer.Clients) { foreach (Session client in roomServer.Clients.Values) { if (client.ServerInfo != null && client.ServerInfo.Port == server.Port) { client.ServerInfo = srv; client.Send(writer.Content); } } } } } }
public static void OnSendServerInfo(this RoomServer roomServer, Session session) { using (PacketWriter writer = new PacketWriter(2)) { writer.Write((byte)RoomMessage.Info); writer.Write(roomServer.GetChatPort()); DuelServer srv = roomServer.GetMinServer(); lock (srv.AsyncLock) { srv.Count++; } if (srv != null) { session.ServerInfo = srv; writer.Write(srv.Port); writer.Write(srv.NeedAuth); } else { writer.Write(0); writer.Write((byte)0); } writer.WriteUnicode(session.Token, 32); session.Send(writer.Content); } }