Esempio n. 1
0
            public SessionHandler(Protocol1ArenaEngine engine)
            {
                this.Engine = engine;

                FirstStageHandlers[Protocol1Constants.COMMAND_VERSION] = new MessageHandler(VersionMatchHandler);
                SecondStageHandlers[Protocol1Constants.COMMAND_LOGIN]  = new MessageHandler(LoginHandler);

                ThirdStageHandlers[Protocol1Constants.COMMAND_INFORM_TUNNEL_UDP_PORT] = new MessageHandler(InformUdpEndPointHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_LOGOUT]      = new MessageHandler(LogoutHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_CHAT]        = new MessageHandler(ChatHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_PING]        = new MessageHandler(PingHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_INFORM_PING] = new MessageHandler(InformPingHandler);
                //ThirdStageHandlers[Protocol1Constants.COMMAND_USER_UPDATE] = new MessageHandler(UserUpdateHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_ROOM_CREATE]      = new MessageHandler(RoomCreateHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_ROOM_UPDATE]      = new MessageHandler(RoomUpdateHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_ROOM_DELETE]      = new MessageHandler(RoomDeleteHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_ROOM_ENTER]       = new MessageHandler(RoomEnterHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_ROOM_EXIT]        = new MessageHandler(RoomExitHandler);
                ThirdStageHandlers[Protocol1Constants.COMMAND_ROOM_KICK_PLAYER] = new MessageHandler(RoomKickUserHandler);
                //ThirdStageHandlers[COMMAND_ADMIN_NOTIFY] = new MessageHandler(AdminNotifyHandler);
            }
Esempio n. 2
0
 public TunnelHandler(Protocol1ArenaEngine engine)
 {
     this.Engine = engine;
 }
Esempio n. 3
0
        public static int Main(String[] args)
        {
            Console.WriteLine("{0}  アリーナサーバー バージョン: {1}", ApplicationConstants.APP_NAME, ApplicationConstants.VERSION);

            IniParser p = new IniParser();

            int port;

            if (!int.TryParse(p.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_PORT), out port))
            {
                port = 30000;
            }

            int maxUsers;

            if (!int.TryParse(p.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_USERS), out maxUsers))
            {
                maxUsers = 20;
            }

            int maxRooms;

            if (!int.TryParse(p.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_ROOMS), out maxRooms))
            {
                maxRooms = 3;
            }

            switch (args.Length)
            {
            case 2:
                maxUsers = Int32.Parse(args[1]);
                port     = Int32.Parse(args[0]);
                break;

            case 1:
                port = Int32.Parse(args[0]);
                break;

            default:
                break;
            }

            p.SetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_PORT, port.ToString());
            p.SetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_USERS, maxUsers.ToString());
            p.SetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_ROOMS, maxRooms.ToString());
            p.SaveSettings();

            Protocol1ArenaEngine engine = new Protocol1ArenaEngine();

            try
            {
                engine.MaxPlayers = maxUsers;
                engine.MaxRooms   = maxRooms;

                engine.StartListening(new IPEndPoint(IPAddress.Any, port));

                while (true)
                {
                    //Console.Write(">");
                    string cmd = Console.ReadLine();
                    //if (cmd == "") break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.ReadLine();
            }
            finally
            {
                engine.StopListening();
            }

            return(0);
        }