Ejemplo n.º 1
0
        public ServerManager(NetworkManager networkManager, Settings.GameSettings gameSettings, PacketManager packetManager, ServerKnightsManager serverKnightsManager)
        {
            _netServer            = networkManager.GetNetServer();
            _gameSettings         = gameSettings;
            _serverKnightsSession = serverKnightsManager.loadSession();
            _playerData           = new ConcurrentDictionary <ushort, ServerPlayerData>();

            // Register packet handlers
            packetManager.RegisterServerPacketHandler <HelloServer>(ServerPacketId.HelloServer, OnHelloServer);
            packetManager.RegisterServerPacketHandler <ServerPlayerEnterScene>(ServerPacketId.PlayerEnterScene, OnClientEnterScene);
            packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerLeaveScene, OnClientLeaveScene);
            packetManager.RegisterServerPacketHandler <PlayerUpdate>(ServerPacketId.PlayerUpdate, OnPlayerUpdate);
            packetManager.RegisterServerPacketHandler <EntityUpdate>(ServerPacketId.EntityUpdate, OnEntityUpdate);
            packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerDisconnect, OnPlayerDisconnect);
            packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerDeath, OnPlayerDeath);
            packetManager.RegisterServerPacketHandler <ServerPlayerTeamUpdate>(ServerPacketId.PlayerTeamUpdate, OnPlayerTeamUpdate);
            packetManager.RegisterServerPacketHandler <ServerServerKnightUpdate>(ServerPacketId.ServerKnightUpdate, OnServerKnightUpdate);

            // Register a heartbeat handler
            _netServer.RegisterOnClientHeartBeat(OnClientHeartBeat);

            // Register server shutdown handler
            _netServer.RegisterOnShutdown(OnServerShutdown);

            // Register application quit handler
            ModHooks.Instance.ApplicationQuitHook += OnApplicationQuit;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 服务器端消息序列化
        /// </summary>
        /// <param name="_sender"></param>
        /// <param name="_type"></param>
        /// <param name="_msgclass"></param>
        /// <returns></returns>
        public static string server_serialization(string _sender, string _type, List <msgClass> _msgclass)
        {
            serverJson one = new serverJson()
            {
                sender = _sender, type = _type, msgclass = _msgclass
            };

            return(JsonConvert.SerializeObject(one));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 服务器端消息序列化
        /// </summary>
        /// <param name="_sender"></param>
        /// <param name="_type"></param>
        /// <param name="_list"></param>
        /// <returns></returns>
        public static string server_serialization(string _sender, string _type, string[] _list)
        {
            serverJson one = new serverJson()
            {
                sender = _sender, type = _type, list = _list
            };

            return(JsonConvert.SerializeObject(one));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 服务器端消息序列化
        /// </summary>
        /// <param name="_sender">接受者</param>
        /// <param name="_msg">消息体</param>
        /// <param name="_type">类型</param>
        /// <param name="_key"></param>
        /// <returns></returns>
        public static string server_serialization(string _sender, string _msg, string _type, string _key)
        {
            serverJson one = new serverJson()
            {
                sender = _sender, msg = _msg, type = _type, key = _key
            };

            return(JsonConvert.SerializeObject(one));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 服务器端消息序列化
        /// </summary>
        /// <param name="_sender">接受者</param>
        /// <param name="_msg">消息体</param>
        /// <returns></returns>
        public static string server_serialization(string _sender, string _msg)
        {
            serverJson one = new serverJson()
            {
                sender = _sender, msg = _msg
            };

            return(JsonConvert.SerializeObject(one));
        }
Ejemplo n.º 6
0
        private void OnServerKnightSession(ServerKnightSession session)
        {
            serverJson sessionJson = new serverJson();

            sessionJson.Name   = session.Name;
            sessionJson.Host   = session.Host;
            sessionJson.skin_1 = session.skin_1;
            sessionJson.skin_2 = session.skin_2;
            sessionJson.skin_3 = session.skin_3;
            sessionJson.skin_4 = session.skin_4;
            sessionJson.skin_5 = session.skin_5;
            sessionJson.skin_6 = session.skin_6;
            sessionJson.skin_7 = session.skin_7;
            sessionJson.skin_8 = session.skin_8;
            sessionJson.skin_9 = session.skin_9;
            _serverKnightsManager.clientSetSession(sessionJson);
        }