private void CreateGameAccount(BnetGameAccountId id, BattleNet.PresenceUpdate update, BnetPlayerChangelist changelist)
    {
        BnetGameAccount account = new BnetGameAccount();

        this.m_gameAccounts.Add(id, account);
        account.SetId(id);
        this.UpdateGameAccount(account, update, changelist);
    }
    private void CreateAccount(BnetAccountId id, BattleNet.PresenceUpdate update, BnetPlayerChangelist changelist)
    {
        BnetAccount account = new BnetAccount();

        this.m_accounts.Add(id, account);
        account.SetId(id);
        BnetPlayer player = null;

        if (!this.m_players.TryGetValue(id, out player))
        {
            player = new BnetPlayer();
            this.m_players.Add(id, player);
            BnetPlayerChange change = new BnetPlayerChange();
            change.SetNewPlayer(player);
            changelist.AddChange(change);
        }
        player.SetAccount(account);
        this.UpdateAccount(account, update, changelist);
    }
Ejemplo n.º 3
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);
    }