Esempio n. 1
0
 private void OnPartyUpdate_JoinedParty(BnetEntityId partyId, BnetGameAccountId otherMemberId)
 {
     if (this.DidSendChallenge() && (this.m_challengee.GetHearthstoneGameAccount().GetId() == otherMemberId))
     {
         if (partyId != this.m_partyId)
         {
             this.m_challengeePartyId = partyId;
             if (this.m_partyId != null)
             {
                 this.ResolveChallengeConflict();
             }
         }
     }
     else if (!BnetUtils.CanReceiveChallengeFrom(otherMemberId))
     {
         Network.DeclineFriendChallenge(partyId);
     }
     else if (!this.AmIAvailable())
     {
         Network.DeclineFriendChallenge(partyId);
     }
     else
     {
         this.HandleJoinedParty(partyId, otherMemberId);
     }
 }
 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[i];
         BnetEntityId entityId = new BnetEntityId();
         entityId.SetLo(friend.Id.Low);
         entityId.SetHi(friend.Id.High);
         this.AddFriendInternal(entityId);
     }
     for (int j = 0; j < response.ReceivedInvitationsCount; j++)
     {
         Invitation invitation = response.ReceivedInvitations[j];
         this.AddInvitationInternal(BattleNet.FriendsUpdate.Action.FRIEND_INVITE, invitation, 0);
     }
     for (int k = 0; k < response.SentInvitationsCount; k++)
     {
         Invitation invitation2 = response.SentInvitations[k];
         this.AddInvitationInternal(BattleNet.FriendsUpdate.Action.FRIEND_SENT_INVITE, invitation2, 0);
     }
 }
    public static BnetEntityId CreateFromDll(BattleNet.DllEntityId src)
    {
        BnetEntityId id = new BnetEntityId();

        id.CopyFrom(src);
        return(id);
    }
Esempio n. 4
0
    public static BnetAccountId CreateFromBnetEntityId(BnetEntityId src)
    {
        BnetAccountId id = new BnetAccountId();

        id.CopyFrom(src);
        return(id);
    }
 private void NotifyFriendRemovedListenerCallback(RPCContext context)
 {
     if (this.m_state == FriendsAPIState.INITIALIZED)
     {
         BnetEntityId entityId = this.ExtractEntityIdFromFriendNotification(context.Payload);
         this.RemoveFriendInternal(entityId);
     }
 }
 public bool Equals(BnetEntityId other)
 {
     if (other == null)
     {
         return(false);
     }
     return((this.m_hi == other.m_hi) && (this.m_lo == other.m_lo));
 }
    public static BnetEntityId CreateFromProtocol(EntityId src)
    {
        BnetEntityId id = new BnetEntityId();

        id.SetLo(src.Low);
        id.SetHi(src.High);
        return(id);
    }
    public static EntityId CreateForProtocol(BnetEntityId src)
    {
        EntityId id = new EntityId();

        id.SetLow(src.GetLo());
        id.SetHigh(src.GetHi());
        return(id);
    }
    public void RemoveFriendsActiveGameAccount(BnetEntityId entityId, ulong index)
    {
        EntityId id;

        if (this.IsFriend(entityId) && this.m_friendEntityId[entityId].TryGetValue(index, out id))
        {
            base.m_battleNet.Presence.PresenceUnsubscribe(id);
            this.m_friendEntityId[entityId].Remove(index);
        }
    }
    private BnetEntityId ExtractEntityIdFromFriendNotification(byte[] payload)
    {
        FriendNotification notification2 = FriendNotification.ParseFrom(payload);

        if (!notification2.IsInitialized)
        {
            return(null);
        }
        return(BnetEntityId.CreateFromProtocol(notification2.Target.Id));
    }
Esempio n. 11
0
 private void ResolveChallengeConflict()
 {
     if (this.m_partyId.GetLo() < this.m_challengeePartyId.GetLo())
     {
         Network.DeclineFriendChallenge(this.m_challengeePartyId);
         this.m_challengeePartyId = this.m_partyId;
     }
     else if (this.m_challengee != null)
     {
         this.HandleJoinedParty(this.m_challengeePartyId, this.m_challengee.GetHearthstoneGameAccount().GetId());
     }
 }
Esempio n. 12
0
 private void OnPartyUpdate_CreatedParty(BnetEntityId partyId, BnetGameAccountId otherMemberId)
 {
     this.m_partyId = partyId;
     if ((this.m_challengeePartyId != null) && (this.m_challengeePartyId != this.m_partyId))
     {
         this.ResolveChallengeConflict();
     }
     else
     {
         this.m_challengeePartyId = this.m_partyId;
         this.UpdateChallengeSentDialog();
     }
 }
 public bool AddFriendsActiveGameAccount(BnetEntityId entityId, EntityId gameAccount, ulong index)
 {
     if (!this.IsFriend(entityId))
     {
         return(false);
     }
     if (!this.m_friendEntityId[entityId].ContainsKey(index))
     {
         this.m_friendEntityId[entityId].Add(index, gameAccount);
         base.m_battleNet.Presence.PresenceSubscribe(gameAccount);
     }
     return(true);
 }
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        BnetEntityId id = obj as BnetEntityId;

        if (id == null)
        {
            return(false);
        }
        return((this.m_hi == id.m_hi) && (this.m_lo == id.m_lo));
    }
 private void AddFriendInternal(BnetEntityId entityId)
 {
     if (entityId != null)
     {
         BattleNet.FriendsUpdate item = new BattleNet.FriendsUpdate {
             action  = 1,
             entity1 = entityId
         };
         this.m_updateList.Add(item);
         base.m_battleNet.Presence.PresenceSubscribe(BnetEntityId.CreateForProtocol(entityId));
         this.m_friendEntityId.Add(entityId, new Map <ulong, EntityId>());
         this.m_friendsCount = (uint)this.m_friendEntityId.Count;
     }
 }
Esempio n. 16
0
 private void CleanUpChallengeData(bool updateAvailability = true)
 {
     this.m_partyId                = null;
     this.m_challengeePartyId      = null;
     this.m_challengerId           = null;
     this.m_challengerPending      = false;
     this.m_challenger             = null;
     this.m_challengerDeckSelected = false;
     this.m_challengee             = null;
     this.m_challengeeAccepted     = false;
     this.m_challengeeDeckSelected = false;
     this.m_scenarioId             = 2;
     this.m_isChallengeTavernBrawl = false;
     if (updateAvailability)
     {
         this.UpdateMyAvailability();
     }
 }
 public bool HasAccount(BnetEntityId id)
 {
     if (id != null)
     {
         if (this.m_accountId == id)
         {
             return(true);
         }
         foreach (BnetGameAccountId id2 in this.m_gameAccounts.Keys)
         {
             if (id2 == id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 18
0
 private void HandleJoinedParty(BnetEntityId partyId, BnetGameAccountId otherMemberId)
 {
     this.m_partyId               = partyId;
     this.m_challengeePartyId     = partyId;
     this.m_challengerId          = otherMemberId;
     this.m_challenger            = BnetUtils.GetPlayer(this.m_challengerId);
     this.m_challengee            = BnetPresenceMgr.Get().GetMyPlayer();
     this.m_hasSeenDeclinedReason = false;
     if ((this.m_challenger == null) || !this.m_challenger.IsDisplayable())
     {
         this.m_challengerPending = true;
         this.UpdateMyAvailability();
     }
     else
     {
         this.UpdateMyAvailability();
         this.FireChangedEvent(FriendChallengeEvent.I_RECEIVED_CHALLENGE, this.m_challenger);
     }
 }
    public static void CreateParty(PartyType partyType, PrivacyLevel privacyLevel, CreateSuccessCallback successCallback)
    {
        string szPartyType = EnumUtils.GetString <PartyType>(partyType);

        if ((s_pendingPartyCreates != null) && s_pendingPartyCreates.ContainsKey(partyType))
        {
            object[] args = new object[] { partyType };
            RaisePartyError(true, szPartyType, BnetFeatureEvent.Party_Create_Callback, 6, "CreateParty: Already creating party of type {0}", args);
        }
        else
        {
            if (s_pendingPartyCreates == null)
            {
                s_pendingPartyCreates = new Map <PartyType, CreateSuccessCallback>();
            }
            s_pendingPartyCreates[partyType] = successCallback;
            byte[] creatorBlob = ProtobufUtil.ToByteArray(BnetEntityId.CreateForNet(BnetPresenceMgr.Get().GetMyGameAccountId()));
            BattleNet.CreateParty(szPartyType, (int)privacyLevel, creatorBlob);
        }
    }
    private BnetEntityId GetBnetEntityIdFromIdentity(Identity identity)
    {
        BnetEntityId id = new BnetEntityId();

        if (identity.HasAccountId)
        {
            id.SetLo(identity.AccountId.Low);
            id.SetHi(identity.AccountId.High);
            return(id);
        }
        if (identity.HasGameAccountId)
        {
            id.SetLo(identity.GameAccountId.Low);
            id.SetHi(identity.GameAccountId.High);
            return(id);
        }
        id.SetLo(0L);
        id.SetHi(0L);
        return(id);
    }
 private void RemoveFriendInternal(BnetEntityId entityId)
 {
     if (entityId != null)
     {
         BattleNet.FriendsUpdate item = new BattleNet.FriendsUpdate {
             action  = 2,
             entity1 = entityId
         };
         this.m_updateList.Add(item);
         base.m_battleNet.Presence.PresenceUnsubscribe(BnetEntityId.CreateForProtocol(entityId));
         if (this.m_friendEntityId.ContainsKey(entityId))
         {
             foreach (EntityId id in this.m_friendEntityId[entityId].Values)
             {
                 base.m_battleNet.Presence.PresenceUnsubscribe(id);
             }
             this.m_friendEntityId.Remove(entityId);
         }
         this.m_friendsCount = (uint)this.m_friendEntityId.Count;
     }
 }
Esempio n. 22
0
 public static PartyId FromBnetEntityId(BnetEntityId entityId)
 {
     return(new PartyId(entityId.GetHi(), entityId.GetLo()));
 }
Esempio n. 23
0
    public void HandlePresenceUpdates(ChannelState channelState, ChannelAPI.ChannelReferenceObject channelRef)
    {
        BattleNet.DllEntityId id;
        id.hi = channelRef.m_channelData.m_channelId.High;
        id.lo = channelRef.m_channelData.m_channelId.Low;
        FieldKey key = new FieldKey();

        key.SetProgram(BnetProgramId.BNET.GetValue());
        key.SetGroup(1);
        key.SetField(3);
        FieldKey key2 = key;
        List <BattleNet.PresenceUpdate> collection = new List <BattleNet.PresenceUpdate>();

        foreach (FieldOperation operation in channelState.FieldOperationList)
        {
            BattleNet.PresenceUpdate item = new BattleNet.PresenceUpdate {
                entityId   = id,
                programId  = operation.Field.Key.Program,
                groupId    = operation.Field.Key.Group,
                fieldId    = operation.Field.Key.Field,
                index      = operation.Field.Key.Index,
                boolVal    = false,
                intVal     = 0L,
                stringVal  = string.Empty,
                valCleared = false,
                blobVal    = new byte[0]
            };
            if (operation.Operation == FieldOperation.Types.OperationType.CLEAR)
            {
                item.valCleared = true;
                bool flag  = key2.Program == operation.Field.Key.Program;
                bool flag2 = key2.Group == operation.Field.Key.Group;
                bool flag3 = key2.Field == operation.Field.Key.Field;
                if ((flag && flag2) && flag3)
                {
                    BnetEntityId entityId = BnetEntityId.CreateFromDll(item.entityId);
                    base.m_battleNet.Friends.RemoveFriendsActiveGameAccount(entityId, operation.Field.Key.Index);
                }
            }
            else if (operation.Field.Value.HasBoolValue)
            {
                item.boolVal = operation.Field.Value.BoolValue;
            }
            else if (operation.Field.Value.HasIntValue)
            {
                item.intVal = operation.Field.Value.IntValue;
            }
            else if (operation.Field.Value.HasStringValue)
            {
                item.stringVal = operation.Field.Value.StringValue;
            }
            else if (operation.Field.Value.HasFourccValue)
            {
                item.stringVal = new BnetProgramId(operation.Field.Value.FourccValue).ToString();
            }
            else if (operation.Field.Value.HasEntityidValue)
            {
                item.entityIdVal.hi = operation.Field.Value.EntityidValue.High;
                item.entityIdVal.lo = operation.Field.Value.EntityidValue.Low;
                bool flag4 = key2.Program == operation.Field.Key.Program;
                bool flag5 = key2.Group == operation.Field.Key.Group;
                bool flag6 = key2.Field == operation.Field.Key.Field;
                if ((flag4 && flag5) && flag6)
                {
                    BnetEntityId id3 = BnetEntityId.CreateFromDll(item.entityId);
                    base.m_battleNet.Friends.AddFriendsActiveGameAccount(id3, operation.Field.Value.EntityidValue, operation.Field.Key.Index);
                }
            }
            else
            {
                if (!operation.Field.Value.HasBlobValue)
                {
                    continue;
                }
                item.blobVal = operation.Field.Value.BlobValue;
            }
            collection.Add(item);
        }
        collection.Reverse();
        this.m_presenceUpdates.AddRange(collection);
    }
 public void SetInviterId(BnetEntityId id)
 {
     this.m_inviterId = id;
 }
 public static BattleNet.DllEntityId CreateForDll(BnetEntityId src)
 {
     return(new BattleNet.DllEntityId {
         hi = src.m_hi, lo = src.m_lo
     });
 }
 public static BnetId CreateForNet(BnetEntityId src)
 {
     return(new BnetId {
         Hi = src.GetHi(), Lo = src.GetLo()
     });
 }
Esempio n. 27
0
 private void OnPartyUpdate(BattleNet.PartyEvent[] updates)
 {
     for (int i = 0; i < updates.Length; i++)
     {
         BattleNet.PartyEvent event2        = updates[i];
         BnetEntityId         partyId       = BnetEntityId.CreateFromDll(event2.partyId);
         BnetGameAccountId    otherMemberId = BnetGameAccountId.CreateFromDll(event2.otherMemberId);
         if (event2.eventName == "s1")
         {
             if (event2.eventData == "wait")
             {
                 this.OnPartyUpdate_CreatedParty(partyId, otherMemberId);
             }
             else if (event2.eventData == "deck")
             {
                 if (this.DidReceiveChallenge() && this.m_challengerDeckSelected)
                 {
                     this.m_challengerDeckSelected = false;
                     this.FireChangedEvent(FriendChallengeEvent.DESELECTED_DECK, this.m_challenger);
                 }
             }
             else if (event2.eventData == "game")
             {
                 if (this.DidReceiveChallenge())
                 {
                     this.m_challengerDeckSelected = true;
                     this.FireChangedEvent(FriendChallengeEvent.SELECTED_DECK, this.m_challenger);
                 }
             }
             else if (event2.eventData == "goto")
             {
                 this.m_challengerDeckSelected = false;
             }
         }
         else if (event2.eventName == "s2")
         {
             if (event2.eventData == "wait")
             {
                 this.OnPartyUpdate_JoinedParty(partyId, otherMemberId);
             }
             else if (event2.eventData == "deck")
             {
                 if (this.DidSendChallenge())
                 {
                     if (this.m_challengeeAccepted)
                     {
                         this.m_challengeeDeckSelected = false;
                         this.FireChangedEvent(FriendChallengeEvent.DESELECTED_DECK, this.m_challengee);
                     }
                     else
                     {
                         this.m_challengeeAccepted = true;
                         this.FireChangedEvent(FriendChallengeEvent.OPPONENT_ACCEPTED_CHALLENGE, this.m_challengee);
                     }
                 }
             }
             else if (event2.eventData == "game")
             {
                 if (this.DidSendChallenge())
                 {
                     this.m_challengeeDeckSelected = true;
                     this.FireChangedEvent(FriendChallengeEvent.SELECTED_DECK, this.m_challengee);
                 }
             }
             else if (event2.eventData == "goto")
             {
                 this.m_challengeeDeckSelected = false;
             }
         }
         else if (event2.eventName == "left")
         {
             if (this.DidSendChallenge())
             {
                 BnetPlayer challengee         = this.m_challengee;
                 bool       challengeeAccepted = this.m_challengeeAccepted;
                 this.RevertTavernBrawlStatus();
                 this.CleanUpChallengeData(true);
                 if (challengeeAccepted)
                 {
                     this.FireChangedEvent(FriendChallengeEvent.OPPONENT_CANCELED_CHALLENGE, challengee);
                 }
                 else
                 {
                     this.FireChangedEvent(FriendChallengeEvent.OPPONENT_DECLINED_CHALLENGE, challengee);
                 }
             }
             else if (this.DidReceiveChallenge())
             {
                 BnetPlayer challenger = this.m_challenger;
                 bool       flag2      = this.m_challengeeAccepted;
                 this.RevertTavernBrawlStatus();
                 this.CleanUpChallengeData(true);
                 if (challenger != null)
                 {
                     if (flag2)
                     {
                         this.FireChangedEvent(FriendChallengeEvent.OPPONENT_CANCELED_CHALLENGE, challenger);
                     }
                     else
                     {
                         this.FireChangedEvent(FriendChallengeEvent.OPPONENT_RESCINDED_CHALLENGE, challenger);
                     }
                 }
             }
         }
     }
 }
 public void CopyFrom(BnetEntityId id)
 {
     this.m_hi = id.m_hi;
     this.m_lo = id.m_lo;
 }
 public bool IsFriend(BnetEntityId entityId)
 {
     return(this.m_friendEntityId.ContainsKey(entityId));
 }
 public bool GetFriendsActiveGameAccounts(BnetEntityId entityId, [Out] Map <ulong, EntityId> gameAccounts)
 {
     return(this.m_friendEntityId.TryGetValue(entityId, out gameAccounts));
 }