Exemplo n.º 1
0
        // TODO: Implement loading existing realms.
        // TODO: Implement existing character counts.
        static async Task HandleRealmListRequest(ClientRequest clientRequest, BnetSession session)
        {
            var realmJoinRequest = clientRequest.GetVariant("Command_RealmListRequest_v1_b9")?.StringValue;
            var realmListTicket  = clientRequest.GetVariant("Param_RealmListTicket")?.BlobValue.ToByteArray();

            if (session.RealmListTicket.Compare(realmListTicket))
            {
                var realmListResponse = new ClientResponse();
                var realmlist         = new RealmListUpdates();

                realmListResponse.Attribute.Add(new Bgs.Protocol.Attribute
                {
                    Name  = "Param_RealmList",
                    Value = new Variant
                    {
                        BlobValue = ByteString.CopyFrom(Deflate("JSONRealmListUpdates", realmlist))
                    }
                });

                var realmCharacterCountList = new RealmCharacterCountList();

                realmListResponse.Attribute.Add(new Bgs.Protocol.Attribute
                {
                    Name  = "Param_CharacterCountList",
                    Value = new Variant
                    {
                        BlobValue = ByteString.CopyFrom(Deflate("JSONRealmCharacterCountList", realmCharacterCountList))
                    }
                });

                await session.Send(realmListResponse);
            }
        }
        // TODO: Verify ClientRequest values.
        static async Task HandleRealmListTicketRequest(ClientRequest clientRequest, BnetSession session)
        {
            var paramIdentityValue = clientRequest.GetVariant("Param_Identity")?.BlobValue.ToStringUtf8();
            var paramClientInfoValue = clientRequest.GetVariant("Param_ClientInfo")?.BlobValue.ToStringUtf8();

            if (paramIdentityValue != null && paramClientInfoValue != null)
            {
                var realmListTicketIdentity = CreateObject<RealmListTicketIdentity>(paramIdentityValue, true);
                var realmListTicketClientInformation = CreateObject<RealmListTicketClientInformation>(paramClientInfoValue, true);

                session.GameAccount = session.Account.GameAccounts.SingleOrDefault(ga => ga.Id == realmListTicketIdentity.GameAccountId);

                if (session.GameAccount != null)
                {
                    session.RealmListSecret = realmListTicketClientInformation.Info.Secret.Select(x => Convert.ToByte(x)).ToArray();
                    session.RealmListTicket = new byte[0].GenerateRandomKey(32);

                    var realmListTicketResponse = new ClientResponse();

                    realmListTicketResponse.Attribute.Add(new Bgs.Protocol.Attribute
                    {
                        Name = "Param_RealmListTicket",
                        Value = new Variant
                        {
                            BlobValue = ByteString.CopyFrom(session.RealmListTicket)
                        }
                    });

                    await session.Send(realmListTicketResponse);
                }
            }
            else
                session.Dispose();
        }
Exemplo n.º 3
0
        // TODO: Implement realm join function.
        static async Task HandleRealmJoinRequest(ClientRequest clientRequest, BnetSession session)
        {
            var realmJoinRequest = clientRequest.GetVariant("Command_RealmJoinRequest_v1_b9")?.StringValue;
            var realmAddress     = clientRequest.GetVariant("Param_RealmAddress")?.UintValue;
            var realmListTicket  = clientRequest.GetVariant("Param_RealmListTicket")?.BlobValue.ToByteArray();
            var bnetSessionKey   = clientRequest.GetVariant("Param_BnetSessionKey")?.BlobValue.ToByteArray();

            // Check for valid realmlist ticket.
            if (realmListTicket.Compare(session.RealmListTicket))
            {
                var realmJoinResponse = new ClientResponse();

                await session.Send(realmJoinResponse);
            }
        }
Exemplo n.º 4
0
        // TODO: Verify ClientRequest values.
        static async Task HandleRealmListTicketRequest(ClientRequest clientRequest, BnetSession session)
        {
            var paramIdentityValue   = clientRequest.GetVariant("Param_Identity")?.BlobValue.ToStringUtf8();
            var paramClientInfoValue = clientRequest.GetVariant("Param_ClientInfo")?.BlobValue.ToStringUtf8();

            if (paramIdentityValue != null && paramClientInfoValue != null)
            {
                var realmListTicketIdentity          = CreateObject <RealmListTicketIdentity>(paramIdentityValue, true);
                var realmListTicketClientInformation = CreateObject <RealmListTicketClientInformation>(paramClientInfoValue, true);

                session.GameAccount = session.Account.GameAccounts.SingleOrDefault(ga => ga.Id == realmListTicketIdentity.GameAccountId);

                if (session.GameAccount != null)
                {
                    session.RealmListSecret = realmListTicketClientInformation.Info.Secret.Select(x => Convert.ToByte(x)).ToArray();
                    session.RealmListTicket = new byte[0].GenerateRandomKey(32);

                    var realmListTicketResponse = new ClientResponse();

                    realmListTicketResponse.Attribute.Add(new Bgs.Protocol.Attribute
                    {
                        Name  = "Param_RealmListTicket",
                        Value = new Variant
                        {
                            BlobValue = ByteString.CopyFrom(session.RealmListTicket)
                        }
                    });

                    await session.Send(realmListTicketResponse);
                }
            }
            else
            {
                session.Dispose();
            }
        }
        // TODO: Implement loading existing realms.
        // TODO: Implement existing character counts.
        static async Task HandleRealmListRequest(ClientRequest clientRequest, BnetSession session)
        {
            var realmJoinRequest = clientRequest.GetVariant("Command_RealmListRequest_v1_b9")?.StringValue;
            var realmListTicket = clientRequest.GetVariant("Param_RealmListTicket")?.BlobValue.ToByteArray();

            if (session.RealmListTicket.Compare(realmListTicket))
            {
                var realmListResponse = new ClientResponse();
                var realmlist = new RealmListUpdates();

                realmListResponse.Attribute.Add(new Bgs.Protocol.Attribute
                {
                    Name = "Param_RealmList",
                    Value = new Variant
                    {
                        BlobValue = ByteString.CopyFrom(Deflate("JSONRealmListUpdates", realmlist))
                    }
                });

                var realmCharacterCountList = new RealmCharacterCountList();

                realmListResponse.Attribute.Add(new Bgs.Protocol.Attribute
                {
                    Name = "Param_CharacterCountList",
                    Value = new Variant
                    {
                        BlobValue = ByteString.CopyFrom(Deflate("JSONRealmCharacterCountList", realmCharacterCountList))
                    }
                });

                await session.Send(realmListResponse);
            }
        }
        // TODO: Implement realm join function.
        static async Task HandleRealmJoinRequest(ClientRequest clientRequest, BnetSession session)
        {
            var realmJoinRequest = clientRequest.GetVariant("Command_RealmJoinRequest_v1_b9")?.StringValue;
            var realmAddress = clientRequest.GetVariant("Param_RealmAddress")?.UintValue;
            var realmListTicket = clientRequest.GetVariant("Param_RealmListTicket")?.BlobValue.ToByteArray();
            var bnetSessionKey = clientRequest.GetVariant("Param_BnetSessionKey")?.BlobValue.ToByteArray();

            // Check for valid realmlist ticket.
            if (realmListTicket.Compare(session.RealmListTicket))
            {
                var realmJoinResponse = new ClientResponse();

                await session.Send(realmJoinResponse);
            }
        }