public static void Initialize(ProudNet.Configuration config)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Server is already initialized");
            }

            config.Version          = new Guid("{a43a97d1-9ec7-495e-ad5f-8fe45fde1151}");
            config.MessageFactories = new MessageFactory[] { new RelayMessageFactory() };
            config.SessionFactory   = new RelaySessionFactory();
            config.Logger           = Logger.ForContext(Constants.SourceContextPropertyName, "RelayServer-ProudNet");

            // ReSharper disable InconsistentNaming
            Predicate <RelaySession> MustNotBeLoggedIn = session => !session.IsLoggedIn();

            // ReSharper restore InconsistentNaming

            config.MessageHandlers = new IMessageHandler[]
            {
                new FilteredMessageHandler <RelaySession>()
                .AddHandler(new AuthService())

                .RegisterRule <CRequestLoginMessage>(MustNotBeLoggedIn)
            };
            Instance = new RelayServer(config);
        }
Beispiel #2
0
        public static void Initialize(ProudNet.Configuration config)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Server is already initialized");
            }

            config.Version          = new Guid("{9be73c0b-3b10-403e-be7d-9f222702a38c}");
            config.MessageFactories = new MessageFactory[] { new AuthMessageFactory() };
            config.MessageHandlers  = new IMessageHandler[] { new AuthService() };
            config.Logger           = Logger.ForContext(Constants.SourceContextPropertyName, "ProudNet");
            Instance = new AuthServer(config);
        }
Beispiel #3
0
        private GameServer(ProudNet.Configuration config)
            : base(config)
        {
            RegisterMappings();

            //ServerTime = TimeSpan.Zero;

            CommandManager = new CommandManager(this);
            CommandManager.Add(new ServerCommand())
            .Add(new ReloadCommand())
            .Add(new GameCommands())
            .Add(new InventoryCommands());

            PlayerManager  = new PlayerManager();
            ResourceCache  = new ResourceCache();
            ChannelManager = new ChannelManager(ResourceCache.GetChannels());

            _worker            = new ThreadLoop(TimeSpan.FromMilliseconds(100), (Action <TimeSpan>)Worker);
            _serverlistManager = new ServerlistManager();
        }
Beispiel #4
0
        public static void Initialize(ProudNet.Configuration config)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Server is already initialized");
            }

            config.Version          = new Guid("{97d36acf-8cc0-4dfb-bcc9-97cab255e2bc}");
            config.MessageFactories = new MessageFactory[] { new ChatMessageFactory() };
            config.SessionFactory   = new ChatSessionFactory();
            config.Logger           = Logger.ForContext(Constants.SourceContextPropertyName, "ChatServer-ProudNet");

            // ReSharper disable InconsistentNaming
            Predicate <ChatSession> MustBeLoggedIn    = session => session.IsLoggedIn();
            Predicate <ChatSession> MustNotBeLoggedIn = session => !session.IsLoggedIn();
            Predicate <ChatSession> MustBeInChannel   = session => session.Player.Channel != null;

            // ReSharper restore InconsistentNaming

            config.MessageHandlers = new IMessageHandler[]
            {
                new FilteredMessageHandler <ChatSession>()
                .AddHandler(new AuthService())
                .AddHandler(new CommunityService())
                .AddHandler(new ChannelService())
                .AddHandler(new PrivateMessageService())

                .RegisterRule <CLoginReqMessage>(MustNotBeLoggedIn)
                .RegisterRule <CSetUserDataReqMessage>(MustBeLoggedIn)
                .RegisterRule <CGetUserDataReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CDenyChatReqMessage>(MustBeLoggedIn)
                .RegisterRule <CChatMessageReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CWhisperChatMessageReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CNoteListReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CReadNoteReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CDeleteNoteReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CSendNoteReqMessage>(MustBeLoggedIn, MustBeInChannel)
            };
            Instance = new ChatServer(config);
        }
Beispiel #5
0
 private AuthServer(ProudNet.Configuration config)
     : base(config)
 {
     _worker       = new TaskLoop(TimeSpan.FromSeconds(10), Worker);
     ServerManager = new ServerManager();
 }
 private RelayServer(ProudNet.Configuration config)
     : base(config)
 {
 }
Beispiel #7
0
        public static void Initialize(ProudNet.Configuration config)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Server is already initialized");
            }

            config.Version          = new Guid("{beb92241-8333-4117-ab92-9b4af78c688f}");
            config.MessageFactories = new MessageFactory[] { new GameMessageFactory(), new GameRuleMessageFactory() };
            config.SessionFactory   = new GameSessionFactory();
            config.Logger           = Logger.ForContext(Constants.SourceContextPropertyName, "GameServer-ProudNet");

            // ReSharper disable InconsistentNaming
            Predicate <GameSession> MustBeLoggedIn     = session => session.IsLoggedIn();
            Predicate <GameSession> MustNotBeLoggedIn  = session => !session.IsLoggedIn();
            Predicate <GameSession> MustBeInChannel    = session => session.Player.Channel != null;
            Predicate <GameSession> MustNotBeInChannel = session => session.Player.Channel == null;
            Predicate <GameSession> MustBeInRoom       = session => session.Player.Room != null;
            Predicate <GameSession> MustNotBeInRoom    = session => session.Player.Room == null;
            Predicate <GameSession> MustBeRoomHost     = session => session.Player.Room.Host == session.Player;
            Predicate <GameSession> MustBeRoomMaster   = session => session.Player.Room.Master == session.Player;

            // ReSharper restore InconsistentNaming

            config.MessageHandlers = new IMessageHandler[]
            {
                new FilteredMessageHandler <GameSession>()
                .AddHandler(new AuthService())
                .AddHandler(new CharacterService())
                .AddHandler(new GeneralService())
                .AddHandler(new AdminService())
                .AddHandler(new ChannelService())
                .AddHandler(new ShopService())
                .AddHandler(new InventoryService())
                .AddHandler(new RoomService())
                .AddHandler(new ClubService())

                .RegisterRule <CLoginReqMessage>(MustNotBeLoggedIn)
                .RegisterRule <CCreateCharacterReqMessage>(MustBeLoggedIn)
                .RegisterRule <CSelectCharacterReqMessage>(MustBeLoggedIn)
                .RegisterRule <CDeleteCharacterReqMessage>(MustBeLoggedIn)
                .RegisterRule <CAdminShowWindowReqMessage>(MustBeLoggedIn)
                .RegisterRule <CAdminActionReqMessage>(MustBeLoggedIn)
                .RegisterRule <CGetChannelInfoReqMessage>(MustBeLoggedIn)
                .RegisterRule <CChannelEnterReqMessage>(MustBeLoggedIn, MustNotBeInChannel)
                .RegisterRule <CChannelLeaveReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CLicensedReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CExerciseLicenceReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CBuyItemReqMessage>(MustBeLoggedIn)
                .RegisterRule <CRandomShopRollingStartReqMessage>(MustBeLoggedIn)
                .RegisterRule <CRandomShopItemSaleReqMessage>(MustBeLoggedIn)
                .RegisterRule <CUseItemReqMessage>(MustBeLoggedIn)
                .RegisterRule <CRepairItemReqMessage>(MustBeLoggedIn)
                .RegisterRule <CRefundItemReqMessage>(MustBeLoggedIn)
                .RegisterRule <CDiscardItemReqMessage>(MustBeLoggedIn)
                .RegisterRule <CEnterPlayerReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom,
                                                       session => session.Player.RoomInfo.IsConnecting)
                .RegisterRule <CMakeRoomReqMessage>(MustBeLoggedIn, MustBeInChannel, MustNotBeInRoom)
                .RegisterRule <CGameRoomEnterReqMessage>(MustBeLoggedIn, MustBeInChannel, MustNotBeInRoom)
                .RegisterRule <CQuickStartReqMessage>(MustBeLoggedIn, MustBeInChannel, MustNotBeInRoom)
                .RegisterRule <CJoinTunnelInfoReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CChangeTeamReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CPlayerGameModeChangeReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreKillReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreKillAssistReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreOffenseReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreOffenseAssistReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreDefenseReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreDefenseAssistReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreTeamKillReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreHealAssistReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreSuicideReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CScoreReboundReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom, MustBeRoomHost,
                                                        session => session.Player.RoomInfo.State != PlayerState.Lobby &&
                                                        session.Player.RoomInfo.State != PlayerState.Spectating)
                .RegisterRule <CScoreGoalReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom, MustBeRoomHost,
                                                     session => session.Player.RoomInfo.State != PlayerState.Lobby &&
                                                     session.Player.RoomInfo.State != PlayerState.Spectating)
                .RegisterRule <CBeginRoundReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom, MustBeRoomMaster)
                .RegisterRule <CReadyRoundReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom,
                                                      session => session.Player.RoomInfo.State == PlayerState.Lobby)
                .RegisterRule <CEventMessageReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CItemsChangeReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom,
                                                       session => session.Player.RoomInfo.State == PlayerState.Lobby)
                .RegisterRule <CAvatarChangeReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom,
                                                        session => session.Player.RoomInfo.State == PlayerState.Lobby ||
                                                        session.Player.Room.GameRuleManager.GameRule.StateMachine.IsInState(
                                                            GameRuleState.HalfTime))
                .RegisterRule <CChangeRuleNotifyReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom,
                                                            MustBeRoomMaster,
                                                            session =>
                                                            session.Player.Room.GameRuleManager.GameRule.StateMachine.IsInState(GameRuleState.Waiting))
                .RegisterRule <CClubAddressReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CClubInfoReqMessage>(MustBeLoggedIn, MustBeInChannel)
                .RegisterRule <CLeavePlayerRequestReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom)
                .RegisterRule <CMixChangeTeamReqMessage>(MustBeLoggedIn, MustBeInChannel, MustBeInRoom, MustBeRoomMaster)
            };

            Instance = new GameServer(config);
        }
Beispiel #8
0
 private ChatServer(ProudNet.Configuration config)
     : base(config)
 {
 }