Example #1
0
        public void TestAccountLoginAck()
        {
            var info = new[]
            {
                new ServerInfo("Test Server", 0, TimeZoneInfo.Local, IPEndPoint.Parse("127.0.0.1"))
            };

            var data = new AccountLoginAck(info).Compile();

            Span <byte> expectedData = stackalloc byte[6 + info.Length * 40];

            var pos = 0;

            expectedData.Write(ref pos, (byte)0xA8); // Packet ID
            expectedData.Write(ref pos, (ushort)expectedData.Length);
            expectedData.Write(ref pos, (byte)0x5D); // Unknown
            expectedData.Write(ref pos, (ushort)info.Length);

            for (var i = 0; i < info.Length; i++)
            {
                var si = info[i];
                expectedData.Write(ref pos, (ushort)i);
                expectedData.WriteAsciiFixed(ref pos, si.Name, 32);
                expectedData.Write(ref pos, (byte)si.FullPercent);
                expectedData.Write(ref pos, (byte)si.TimeZone);
                expectedData.Write(ref pos, Utility.GetAddressValue(si.Address.Address));
            }

            AssertThat.Equal(data, expectedData);
        }
Example #2
0
    private void OnReq_Login(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AccountLoginReq        req = Serializer.Deserialize <AccountLoginReq>(ms);
        AccountLoginAck        ack = new AccountLoginAck();

        NetworkManager.Instance.Send(MessageID.MSG_ACCOUNT_LOGIN_ACK, ack, 0, 0);
    }
Example #3
0
    //响应账号登录成功
    private void OnAck_AccountLogin(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AccountLoginAck        ack = Serializer.Deserialize <AccountLoginAck>(ms);

        ClientServerNode newNode = new ClientServerNode();

        newNode.SvrID   = ack.LastSvrID;
        newNode.SvrName = ack.LastSvrName;
        LoginModule.Instance.SetCurrServer(newNode);
        LoginModule.Instance.LastAccountID = ack.AccountID;

        GTEventCenter.FireEvent(GTEventID.TYPE_ACCLOGIN_CALLBACK);
    }
Example #4
0
    private void OnAck_AccountLogin(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AccountLoginAck        ack = Serializer.Deserialize <AccountLoginAck>(ms);

        if (GTItemHelper.ShowNetworkError(ack.RetCode) == false)
        {
            return;
        }
        ClientServerNode newNode = new ClientServerNode();

        newNode.SvrID   = ack.LastSvrID;
        newNode.SvrName = ack.LastSvrName;
        MLLogin.Instance.SetCurrServer(newNode);
        MLLogin.Instance.LastAccountID = ack.AccountID;
        GTEventCenter.FireEvent(GTEventID.TYPE_LOGIN_ACCOUNT_LOGIN);
    }