示例#1
0
 private static void LobbySelectHandler(PacketHeader header, Connection connection, string message)
 {
     NetworkGame.Unregister(connection);
     connection.SendObject("LobbyRoomQuit");
     LobbyRoom.Unregister(connection);
     Program.clientInfos.IsRun = false;
     Connect(connection);
 }
示例#2
0
        private static void LobbyInfoHandler(PacketHeader header, Connection connection, string message)
        {
            Console.WriteLine(message);
            NetworkGame.Register(connection);
            LobbyRoom.Register(connection);

            Program.clientInfos.IsRun = true;
            IsGameStarted             = false;
            Console.WriteLine("Send message to lobby: ");
            while (Program.clientInfos.IsRun)
            {
                string msg;
                bool   success = Reader.TryReadLine(out msg, 100);
                if (!success)
                {
                    continue;
                }
                else
                {
                    Console.WriteLine("Send message to lobby: ");
                }

                if (msg.StartsWith("/quit"))
                {
                    Program.clientInfos.IsRun = false;
                }
                else if (msg.StartsWith("/ready"))
                {
                    NetworkGame.SendReady(connection);
                    IsGameStarted             = true;
                    Program.clientInfos.IsRun = false;
                }
                else
                {
                    connection.SendObject("LobbyRoomMessage", msg);
                }
            }
            if (!IsGameStarted)
            {
                NetworkGame.Unregister(connection);
                connection.SendObject("LobbyRoomQuit");
                LobbyRoom.Unregister(connection);
            }
        }