Exemple #1
0
        public static BnetEntityId CreateFromEntityId(bgs.types.EntityId src)
        {
            BnetEntityId bnetEntityId = new BnetEntityId();

            bnetEntityId.CopyFrom(src);
            return(bnetEntityId);
        }
Exemple #2
0
        public static void IgnoreInviteRequest(PartyId partyId, BnetGameAccountId requestedTargetId)
        {
            EntityId partyId2           = partyId.ToEntityId();
            EntityId requestedTargetId2 = BnetEntityId.CreateEntityId(requestedTargetId);

            BattleNet.IgnoreInviteRequest(partyId2, requestedTargetId2);
        }
 private void ProcessSubscribeToFriendsResponse(SubscribeToFriendsResponse response)
 {
     if (response.HasMaxFriends)
     {
         this.m_maxFriends = response.MaxFriends;
     }
     if (response.HasMaxReceivedInvitations)
     {
         this.m_maxReceivedInvitations = response.MaxReceivedInvitations;
     }
     if (response.HasMaxSentInvitations)
     {
         this.m_maxSentInvitations = response.MaxSentInvitations;
     }
     for (int i = 0; i < response.FriendsCount; i++)
     {
         Friend       friend       = response.Friends.get_Item(i);
         BnetEntityId bnetEntityId = new BnetEntityId();
         bnetEntityId.SetLo(friend.Id.Low);
         bnetEntityId.SetHi(friend.Id.High);
         this.AddFriendInternal(bnetEntityId);
     }
     for (int j = 0; j < response.ReceivedInvitationsCount; j++)
     {
         Invitation invitation = response.ReceivedInvitations.get_Item(j);
         this.AddInvitationInternal(FriendsUpdate.Action.FRIEND_INVITE, invitation, 0);
     }
     for (int k = 0; k < response.SentInvitationsCount; k++)
     {
         Invitation invitation2 = response.SentInvitations.get_Item(k);
         this.AddInvitationInternal(FriendsUpdate.Action.FRIEND_SENT_INVITE, invitation2, 0);
     }
 }
Exemple #4
0
        public static BnetAccountId CreateFromBnetEntityId(BnetEntityId src)
        {
            BnetAccountId bnetAccountId = new BnetAccountId();

            bnetAccountId.CopyFrom(src);
            return(bnetAccountId);
        }
Exemple #5
0
 public static bnet.protocol.EntityId CreateForProtocol(BnetEntityId src)
 {
     bnet.protocol.EntityId entityId = new bnet.protocol.EntityId();
     entityId.SetLow(src.GetLo());
     entityId.SetHigh(src.GetHi());
     return(entityId);
 }
Exemple #6
0
 private void ProcessSubscribeToFriendsResponse(SubscribeToFriendsResponse response)
 {
     if (response.HasMaxFriends)
     {
         this.m_maxFriends = response.MaxFriends;
     }
     if (response.HasMaxReceivedInvitations)
     {
         this.m_maxReceivedInvitations = response.MaxReceivedInvitations;
     }
     if (response.HasMaxSentInvitations)
     {
         this.m_maxSentInvitations = response.MaxSentInvitations;
     }
     for (int i = 0; i < response.FriendsCount; i++)
     {
         Friend       item         = response.Friends[i];
         BnetEntityId bnetEntityId = new BnetEntityId();
         bnetEntityId.SetLo(item.Id.Low);
         bnetEntityId.SetHi(item.Id.High);
         this.AddFriendInternal(bnetEntityId);
     }
     for (int j = 0; j < response.ReceivedInvitationsCount; j++)
     {
         this.AddInvitationInternal(FriendsUpdate.Action.FRIEND_INVITE, response.ReceivedInvitations[j], 0);
     }
     for (int k = 0; k < response.SentInvitationsCount; k++)
     {
         this.AddInvitationInternal(FriendsUpdate.Action.FRIEND_SENT_INVITE, response.SentInvitations[k], 0);
     }
 }
Exemple #7
0
 public bool GetFriendsActiveGameAccounts(BnetEntityId entityId, [Out] Map <ulong, bnet.protocol.EntityId> gameAccounts)
 {
     if (this.m_friendEntityId.TryGetValue(entityId, out gameAccounts))
     {
         return(true);
     }
     return(false);
 }
Exemple #8
0
        public static BnetEntityId CreateFromProtocol(bnet.protocol.EntityId src)
        {
            BnetEntityId bnetEntityId = new BnetEntityId();

            bnetEntityId.SetLo(src.Low);
            bnetEntityId.SetHi(src.High);
            return(bnetEntityId);
        }
Exemple #9
0
 public static bgs.types.EntityId CreateEntityId(BnetEntityId src)
 {
     return(new bgs.types.EntityId
     {
         hi = src.m_hi,
         lo = src.m_lo
     });
 }
Exemple #10
0
 public bool Equals(BnetEntityId other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.m_hi != other.m_hi ? false : this.m_lo == other.m_lo);
 }
Exemple #11
0
 public void RemoveFriendsActiveGameAccount(BnetEntityId entityId, ulong index)
 {
     bnet.protocol.EntityId entityId1;
     if (this.IsFriend(entityId) && this.m_friendEntityId[entityId].TryGetValue(index, out entityId1))
     {
         this.m_battleNet.Presence.PresenceUnsubscribe(entityId1);
         this.m_friendEntityId[entityId].Remove(index);
     }
 }
Exemple #12
0
 public static bgs.types.EntityId CreateEntityId(BnetEntityId src)
 {
     bgs.types.EntityId entityId = new bgs.types.EntityId()
     {
         hi = src.m_hi,
         lo = src.m_lo
     };
     return(entityId);
 }
Exemple #13
0
        private BnetEntityId ExtractEntityIdFromFriendNotification(byte[] payload)
        {
            FriendNotification friendNotification = FriendNotification.ParseFrom(payload);

            if (!friendNotification.IsInitialized)
            {
                return(null);
            }
            return(BnetEntityId.CreateFromProtocol(friendNotification.Target.Id));
        }
        private void NotifyFriendRemovedListenerCallback(RPCContext context)
        {
            if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED)
            {
                return;
            }
            BnetEntityId entityId = this.ExtractEntityIdFromFriendNotification(context.Payload);

            this.RemoveFriendInternal(entityId);
        }
Exemple #15
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            BnetEntityId bnetEntityId = obj as BnetEntityId;

            return(bnetEntityId != null && this.m_hi == bnetEntityId.m_hi && this.m_lo == bnetEntityId.m_lo);
        }
Exemple #16
0
        public static void SendInvite(PartyId toWhichPartyId, BnetGameAccountId recipientId)
        {
            if (!BnetParty.IsInParty(toWhichPartyId))
            {
                return;
            }
            EntityId partyId   = toWhichPartyId.ToEntityId();
            EntityId inviteeId = BnetEntityId.CreateEntityId(recipientId);

            BattleNet.SendPartyInvite(partyId, inviteeId, false);
        }
Exemple #17
0
        public static void KickMember(PartyId partyId, BnetGameAccountId memberId)
        {
            if (!BnetParty.IsInParty(partyId))
            {
                return;
            }
            EntityId partyId2  = partyId.ToEntityId();
            EntityId memberId2 = BnetEntityId.CreateEntityId(memberId);

            BattleNet.KickPartyMember(partyId2, memberId2);
        }
Exemple #18
0
 public bool AddFriendsActiveGameAccount(BnetEntityId entityId, bnet.protocol.EntityId gameAccount, ulong index)
 {
     if (!this.IsFriend(entityId))
     {
         return(false);
     }
     if (!this.m_friendEntityId[entityId].ContainsKey(index))
     {
         this.m_friendEntityId[entityId].Add(index, gameAccount);
         this.m_battleNet.Presence.PresenceSubscribe(gameAccount);
     }
     return(true);
 }
Exemple #19
0
        public static void SetLeader(PartyId partyId, BnetGameAccountId memberId)
        {
            if (!BnetParty.IsInParty(partyId))
            {
                return;
            }
            EntityId  partyId2     = partyId.ToEntityId();
            EntityId  memberId2    = BnetEntityId.CreateEntityId(memberId);
            PartyType partyType    = BnetParty.GetPartyType(partyId);
            uint      leaderRoleId = PartyMember.GetLeaderRoleId(partyType);

            BattleNet.AssignPartyRole(partyId2, memberId2, leaderRoleId);
        }
Exemple #20
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            BnetEntityId bnetEntityId = obj as BnetEntityId;

            if (bnetEntityId == null)
            {
                return(false);
            }
            return(this.m_hi != bnetEntityId.m_hi ? false : this.m_lo == bnetEntityId.m_lo);
        }
        private void AddFriendInternal(BnetEntityId entityId)
        {
            if (entityId == null)
            {
                return;
            }
            FriendsUpdate friendsUpdate = default(FriendsUpdate);

            friendsUpdate.action  = 1;
            friendsUpdate.entity1 = entityId;
            this.m_updateList.Add(friendsUpdate);
            this.m_battleNet.Presence.PresenceSubscribe(BnetEntityId.CreateForProtocol(entityId));
            this.m_friendEntityId.Add(entityId, new Map <ulong, bnet.protocol.EntityId>());
            this.m_friendsCount = (uint)this.m_friendEntityId.Count;
        }
Exemple #22
0
        private BnetEntityId GetBnetEntityIdFromIdentity(Identity identity)
        {
            BnetEntityId bnetEntityId = new BnetEntityId();

            if (identity.HasAccountId)
            {
                bnetEntityId.SetLo(identity.AccountId.Low);
                bnetEntityId.SetHi(identity.AccountId.High);
            }
            else if (!identity.HasGameAccountId)
            {
                bnetEntityId.SetLo((ulong)0);
                bnetEntityId.SetHi((ulong)0);
            }
            else
            {
                bnetEntityId.SetLo(identity.GameAccountId.Low);
                bnetEntityId.SetHi(identity.GameAccountId.High);
            }
            return(bnetEntityId);
        }
        private void RemoveFriendInternal(BnetEntityId entityId)
        {
            if (entityId == null)
            {
                return;
            }
            FriendsUpdate friendsUpdate = default(FriendsUpdate);

            friendsUpdate.action  = 2;
            friendsUpdate.entity1 = entityId;
            this.m_updateList.Add(friendsUpdate);
            this.m_battleNet.Presence.PresenceUnsubscribe(BnetEntityId.CreateForProtocol(entityId));
            if (this.m_friendEntityId.ContainsKey(entityId))
            {
                foreach (bnet.protocol.EntityId current in this.m_friendEntityId[entityId].Values)
                {
                    this.m_battleNet.Presence.PresenceUnsubscribe(current);
                }
                this.m_friendEntityId.Remove(entityId);
            }
            this.m_friendsCount = (uint)this.m_friendEntityId.Count;
        }
Exemple #24
0
        public static void RequestInvite(PartyId partyId, BnetGameAccountId whomToAskForApproval, BnetGameAccountId whomToInvite, PartyType partyType)
        {
            if (BnetParty.IsLeader(partyId))
            {
                PartyError error = default(PartyError);
                error.IsOperationCallback = true;
                error.DebugContext        = "RequestInvite";
                error.ErrorCode           = BattleNetErrors.ERROR_INVALID_TARGET_ID;
                error.Feature             = BnetFeature.Party;
                error.FeatureEvent        = BnetFeatureEvent.Party_RequestPartyInvite_Callback;
                error.PartyId             = partyId;
                error.szPartyType         = EnumUtils.GetString <PartyType>(partyType);
                error.StringData          = "leaders cannot RequestInvite - use SendInvite instead.";
                BnetParty.OnError(error);
                return;
            }
            EntityId partyId2 = partyId.ToEntityId();
            EntityId whomToAskForApproval2 = BnetEntityId.CreateEntityId(whomToAskForApproval);
            EntityId whomToInvite2         = BnetEntityId.CreateEntityId(whomToInvite);
            string   @string = EnumUtils.GetString <PartyType>(partyType);

            BattleNet.RequestPartyInvite(partyId2, whomToAskForApproval2, whomToInvite2, @string);
        }
Exemple #25
0
        public void HandlePresenceUpdates(ChannelState channelState, ChannelAPI.ChannelReferenceObject channelRef)
        {
            bgs.types.EntityId high = new bgs.types.EntityId();
            high.hi = channelRef.m_channelData.m_channelId.High;
            high.lo = channelRef.m_channelData.m_channelId.Low;
            FieldKey fieldKey = new FieldKey();

            fieldKey.SetProgram(BnetProgramId.BNET.GetValue());
            fieldKey.SetGroup(1);
            fieldKey.SetField(3);
            FieldKey fieldKey1 = fieldKey;
            List <PresenceUpdate> presenceUpdates = new List <PresenceUpdate>();

            foreach (FieldOperation fieldOperationList in channelState.FieldOperationList)
            {
                if (fieldOperationList.Operation != FieldOperation.Types.OperationType.CLEAR)
                {
                    this.m_presenceCache.SetCache(high, fieldOperationList.Field.Key, fieldOperationList.Field.Value);
                }
                else
                {
                    this.m_presenceCache.SetCache(high, fieldOperationList.Field.Key, null);
                }
                PresenceUpdate boolValue = new PresenceUpdate()
                {
                    entityId   = high,
                    programId  = fieldOperationList.Field.Key.Program,
                    groupId    = fieldOperationList.Field.Key.Group,
                    fieldId    = fieldOperationList.Field.Key.Field,
                    index      = fieldOperationList.Field.Key.Index,
                    boolVal    = false,
                    intVal     = (long)0,
                    stringVal  = string.Empty,
                    valCleared = false,
                    blobVal    = new byte[0]
                };
                if (fieldOperationList.Operation == FieldOperation.Types.OperationType.CLEAR)
                {
                    boolValue.valCleared = true;
                    bool program = fieldKey1.Program == fieldOperationList.Field.Key.Program;
                    bool group   = fieldKey1.Group == fieldOperationList.Field.Key.Group;
                    bool field   = fieldKey1.Field == fieldOperationList.Field.Key.Field;
                    if (program && group && field)
                    {
                        BnetEntityId bnetEntityId = BnetEntityId.CreateFromEntityId(boolValue.entityId);
                        this.m_battleNet.Friends.RemoveFriendsActiveGameAccount(bnetEntityId, fieldOperationList.Field.Key.Index);
                    }
                }
                else if (fieldOperationList.Field.Value.HasBoolValue)
                {
                    boolValue.boolVal = fieldOperationList.Field.Value.BoolValue;
                }
                else if (fieldOperationList.Field.Value.HasIntValue)
                {
                    boolValue.intVal = fieldOperationList.Field.Value.IntValue;
                }
                else if (fieldOperationList.Field.Value.HasStringValue)
                {
                    boolValue.stringVal = fieldOperationList.Field.Value.StringValue;
                }
                else if (fieldOperationList.Field.Value.HasFourccValue)
                {
                    boolValue.stringVal = (new BnetProgramId(fieldOperationList.Field.Value.FourccValue)).ToString();
                }
                else if (fieldOperationList.Field.Value.HasEntityidValue)
                {
                    boolValue.entityIdVal.hi = fieldOperationList.Field.Value.EntityidValue.High;
                    boolValue.entityIdVal.lo = fieldOperationList.Field.Value.EntityidValue.Low;
                    bool flag   = fieldKey1.Program == fieldOperationList.Field.Key.Program;
                    bool group1 = fieldKey1.Group == fieldOperationList.Field.Key.Group;
                    bool field1 = fieldKey1.Field == fieldOperationList.Field.Key.Field;
                    if (flag && group1 && field1)
                    {
                        BnetEntityId bnetEntityId1 = BnetEntityId.CreateFromEntityId(boolValue.entityId);
                        this.m_battleNet.Friends.AddFriendsActiveGameAccount(bnetEntityId1, fieldOperationList.Field.Value.EntityidValue, fieldOperationList.Field.Key.Index);
                    }
                }
                else if (fieldOperationList.Field.Value.HasBlobValue)
                {
                    boolValue.blobVal = fieldOperationList.Field.Value.BlobValue;
                }
                else if (!fieldOperationList.Field.Value.HasMessageValue)
                {
                    continue;
                }
                else if (fieldOperationList.Field.Key.Field != 8)
                {
                    continue;
                }
                else
                {
                    this.FetchRichPresenceResource(fieldOperationList.Field.Value);
                    this.HandleRichPresenceUpdate(boolValue, fieldOperationList.Field.Key);
                    continue;
                }
                presenceUpdates.Add(boolValue);
            }
            presenceUpdates.Reverse();
            this.m_presenceUpdates.AddRange(presenceUpdates);
        }
Exemple #26
0
 public void CopyFrom(BnetEntityId id)
 {
     this.m_hi = id.m_hi;
     this.m_lo = id.m_lo;
 }
        public void HandlePresenceUpdates(ChannelState channelState, ChannelAPI.ChannelReferenceObject channelRef)
        {
            bgs.types.EntityId entityId;
            entityId.hi = channelRef.m_channelData.m_channelId.High;
            entityId.lo = channelRef.m_channelData.m_channelId.Low;
            FieldKey fieldKey = new FieldKey();

            fieldKey.SetProgram(BnetProgramId.BNET.GetValue());
            fieldKey.SetGroup(1u);
            fieldKey.SetField(3u);
            FieldKey fieldKey2         = fieldKey;
            List <PresenceUpdate> list = new List <PresenceUpdate>();

            foreach (FieldOperation fieldOperation in channelState.FieldOperationList)
            {
                if (fieldOperation.Operation == FieldOperation.Types.OperationType.CLEAR)
                {
                    this.m_presenceCache.SetCache(entityId, fieldOperation.Field.Key, null);
                }
                else
                {
                    this.m_presenceCache.SetCache(entityId, fieldOperation.Field.Key, fieldOperation.Field.Value);
                }
                PresenceUpdate presenceUpdate = default(PresenceUpdate);
                presenceUpdate.entityId   = entityId;
                presenceUpdate.programId  = fieldOperation.Field.Key.Program;
                presenceUpdate.groupId    = fieldOperation.Field.Key.Group;
                presenceUpdate.fieldId    = fieldOperation.Field.Key.Field;
                presenceUpdate.index      = fieldOperation.Field.Key.Index;
                presenceUpdate.boolVal    = false;
                presenceUpdate.intVal     = 0L;
                presenceUpdate.stringVal  = string.Empty;
                presenceUpdate.valCleared = false;
                presenceUpdate.blobVal    = new byte[0];
                if (fieldOperation.Operation == FieldOperation.Types.OperationType.CLEAR)
                {
                    presenceUpdate.valCleared = true;
                    bool flag  = fieldKey2.Program == fieldOperation.Field.Key.Program;
                    bool flag2 = fieldKey2.Group == fieldOperation.Field.Key.Group;
                    bool flag3 = fieldKey2.Field == fieldOperation.Field.Key.Field;
                    if (flag && flag2 && flag3)
                    {
                        BnetEntityId entityId2 = BnetEntityId.CreateFromEntityId(presenceUpdate.entityId);
                        this.m_battleNet.Friends.RemoveFriendsActiveGameAccount(entityId2, fieldOperation.Field.Key.Index);
                    }
                }
                else if (fieldOperation.Field.Value.HasBoolValue)
                {
                    presenceUpdate.boolVal = fieldOperation.Field.Value.BoolValue;
                }
                else if (fieldOperation.Field.Value.HasIntValue)
                {
                    presenceUpdate.intVal = fieldOperation.Field.Value.IntValue;
                }
                else if (fieldOperation.Field.Value.HasStringValue)
                {
                    presenceUpdate.stringVal = fieldOperation.Field.Value.StringValue;
                }
                else if (fieldOperation.Field.Value.HasFourccValue)
                {
                    presenceUpdate.stringVal = new BnetProgramId(fieldOperation.Field.Value.FourccValue).ToString();
                }
                else if (fieldOperation.Field.Value.HasEntityidValue)
                {
                    presenceUpdate.entityIdVal.hi = fieldOperation.Field.Value.EntityidValue.High;
                    presenceUpdate.entityIdVal.lo = fieldOperation.Field.Value.EntityidValue.Low;
                    bool flag4 = fieldKey2.Program == fieldOperation.Field.Key.Program;
                    bool flag5 = fieldKey2.Group == fieldOperation.Field.Key.Group;
                    bool flag6 = fieldKey2.Field == fieldOperation.Field.Key.Field;
                    if (flag4 && flag5 && flag6)
                    {
                        BnetEntityId entityId3 = BnetEntityId.CreateFromEntityId(presenceUpdate.entityId);
                        this.m_battleNet.Friends.AddFriendsActiveGameAccount(entityId3, fieldOperation.Field.Value.EntityidValue, fieldOperation.Field.Key.Index);
                    }
                }
                else if (fieldOperation.Field.Value.HasBlobValue)
                {
                    presenceUpdate.blobVal = fieldOperation.Field.Value.BlobValue;
                }
                else
                {
                    if (!fieldOperation.Field.Value.HasMessageValue)
                    {
                        continue;
                    }
                    if (fieldOperation.Field.Key.Field == 8u)
                    {
                        this.FetchRichPresenceResource(fieldOperation.Field.Value);
                        this.HandleRichPresenceUpdate(presenceUpdate, fieldOperation.Field.Key);
                        continue;
                    }
                    continue;
                }
                list.Add(presenceUpdate);
            }
            list.Reverse();
            this.m_presenceUpdates.AddRange(list);
        }
Exemple #28
0
 public bool Equals(BnetEntityId other)
 {
     return(other != null && this.m_hi == other.m_hi && this.m_lo == other.m_lo);
 }
		public static PartyId FromBnetEntityId(BnetEntityId entityId)
		{
			return new PartyId(entityId.GetHi(), entityId.GetLo());
		}
Exemple #30
0
 public bool IsFriend(BnetEntityId entityId)
 {
     return(this.m_friendEntityId.ContainsKey(entityId));
 }