Exemple #1
0
        private void NotifyLoginLost(CharacterInfoEx characterInfo)
        {
            var desc = new ServiceDesc();

            desc.ServiceType = (int)ServiceType.Login;
            desc.ClientId    = characterInfo.ClientId;
            desc.CharacterId = characterInfo.CharacterId;
            desc.FuncId      = 2033;

            var msgData = new __RPC_Login_GateDisconnect_ARG_uint64_clientId_uint64_characterId__();

            using (var ms = new MemoryStream())
            {
                Serializer.Serialize(ms, msgData);
                desc.Data = ms.ToArray();
            }

            desc.PacketId = 0;


            List <SocketClient> serverClient;

            if (mFromId2Servers.TryGetValue(ServiceType.Login, out serverClient))
            {
                serverClient[0].SendMessage(desc);
            }
        }
        //-----------------------------------------------------SocketListener------------------------
        //客户端链接进来时
        private void OnSocketListenerConnectedEx(ServerClient sender)
        {
            int i = 0;

            if (BlackList.TryGetValue(((IPEndPoint)sender.RemoteEndPoint).Address, out i))
            {
                //sender.SendMessage(new ServiceDesc{Type = (byte)MessageType.DROP, ClientId = 30});
                sender.Disconnect();
                return;
            }

            sender.MessageReceived += OnSocketListenerMessageReceivedEx;
            var clientId = GetUniqueClientId((uint)mId, sender.ClientId);
            //Logger.Fatal("Gate Connect ------ 1---{0} -- {1}", DateTime.Now.ToBinary(), clientId);
            var characterInfo = new CharacterInfoEx();

            characterInfo.mState   = GateClientState.NotAuthorized;
            characterInfo.ClientId = clientId;

            Logger.Info("Client: " + clientId + " connected.");

            sender.UserData = characterInfo;
            mFromClientId2Client.AddOrUpdate(characterInfo.ClientId, sender, (l, arg2) => sender);
        }