Пример #1
0
        public override void Initialize(IServer server)
        {
            // Set handlers
            server.RegisterMessageHandler((short)MstMessageCodes.PickUsername, OnPickUsernameRequestHandler);
            server.RegisterMessageHandler((short)MstMessageCodes.JoinChannel, OnJoinChannelRequestHandler);
            server.RegisterMessageHandler((short)MstMessageCodes.LeaveChannel, OnLeaveChannelRequestHandler);
            server.RegisterMessageHandler((short)MstMessageCodes.GetCurrentChannels, OnGetCurrentChannelsRequestHandler);
            server.RegisterMessageHandler((short)MstMessageCodes.ChatMessage, OnChatMessageHandler);
            server.RegisterMessageHandler((short)MstMessageCodes.GetUsersInChannel, OnGetUsersInChannelRequestHandler);
            server.RegisterMessageHandler((short)MstMessageCodes.SetDefaultChannel, OnSetDefaultChannelRequestHandler);

            // Setup authModule dependencies
            authModule = server.GetModule <AuthModule>();

            // Setup censorModule
            censorModule = server.GetModule <CensorModule>();

            if (useAuthModule && authModule != null)
            {
                authModule.OnUserLoggedInEvent  += OnUserLoggedInEventHandler;
                authModule.OnUserLoggedOutEvent += OnUserLoggedOutEventHandler;
            }
            else if (useAuthModule)
            {
                logger.Error("Chat module was set to use Auth module, but Auth module was not found");
            }
        }
Пример #2
0
        public override void Initialize(IServer server)
        {
            profileDatabaseAccessor = Mst.Server.DbAccessors.GetAccessor <IProfilesDatabaseAccessor>();

            if (profileDatabaseAccessor == null)
            {
                logger.Error("Profiles database implementation was not found");
            }

            // Auth dependency setup
            authModule = server.GetModule <AuthModule>();

            if (authModule != null)
            {
                authModule.OnUserLoggedInEvent += OnUserLoggedInEventHandler;
            }

            // Games dependency setup
            server.SetHandler((short)MstMessageCodes.ServerProfileRequest, GameServerProfileRequestHandler);
            server.SetHandler((short)MstMessageCodes.UpdateServerProfile, ProfileUpdateHandler);
            server.SetHandler((short)MstMessageCodes.ClientProfileRequest, ClientProfileRequestHandler);
        }