public static void OnCreateGame(GameSession client, GameClientPacket packet)
        {
            if (string.IsNullOrEmpty(client.Name) || client.Type != (int)PlayerType.Undefined)
            {
                return;
            }
            GameRoom room = null;

            byte[]         data = packet.ReadBytes(StructTransformer.SizeOf(typeof(CtosCreateGame)));
            CtosCreateGame roomconfig;
            GameConfig     config = null;

            try
            {
                roomconfig = (CtosCreateGame)StructTransformer.BytesToStruct(data, typeof(CtosCreateGame));
                config     = roomconfig.Build();
            }
            catch (Exception e)
            {
                Logger.Warn(e);
            }
            if (config == null)
            {
                client.CloseAsync();
                return;
            }
            room = RoomManager.CreateOrGetGame(config);

            if (room == null)
            {
                client.LobbyError(Messages.MSG_FULL);
                return;
            }
            client.Game = room;
            lock (room.AsyncRoot)
            {
                room.AddPlayer(client);
            }
            //IsAuthentified = CheckAuth();
            if (!client.IsAuthentified)
            {
                client.LobbyError(Messages.ERR_AUTH_FAIL);
            }
        }
 public static void SendRoomList(this RoomServer roomServer, Session session)
 {
     lock (roomServer.DuelServers)
     {
         foreach (DuelServer srv in roomServer.DuelServers)
         {
             lock (srv.Rooms)
             {
                 foreach (GameConfig game in srv.Rooms.Values)
                 {
                     using (PacketWriter packet = new PacketWriter(2))
                     {
                         packet.Write((ushort)RoomMessage.NETWORK_CLIENT_ID);
                         StocHostPacket hp = new StocHostPacket();
                         hp.port = (ushort)srv.Port;
                         hp.host = game.ToHostInfo();
                         hp.name = new char[20];
                         char[] name = game.HasPassword() ? game.RoomString.ToCharArray() : game.Name.ToCharArray();
                         Array.Copy(name, hp.name, Math.Min(20, name.Length));
                         if (game.IsStart)
                         {
                             int i = 20;
                             while (--i > 4)
                             {
                                 hp.name[i] = hp.name[i - 5];
                             }
                             hp.name[0] = '【';
                             hp.name[1] = '对';
                             hp.name[2] = '战';
                             hp.name[3] = '中';
                             hp.name[4] = '】';
                         }
                         packet.Write(StructTransformer.StructToBytes(hp));
                         session.Send(packet.Content, false);
                     }
                 }
             }
             session.PeekSend();
         }
     }
 }