Example #1
0
    public void PublishRichPresence([In] BattleNet.DllRichPresenceUpdate[] updates)
    {
        UpdateRequest updateRequest = new UpdateRequest {
            EntityId = base.m_battleNet.GameAccountId
        };
        FieldOperation val   = new FieldOperation();
        Field          field = new Field();
        FieldKey       key   = new FieldKey();

        key.SetProgram(BnetProgramId.BNET.GetValue());
        key.SetGroup(2);
        key.SetField(8);
        foreach (BattleNet.DllRichPresenceUpdate update in updates)
        {
            key.SetIndex(update.presenceFieldIndex);
            bnet.protocol.presence.RichPresence protobuf = new bnet.protocol.presence.RichPresence();
            protobuf.SetIndex(update.index);
            protobuf.SetProgramId(update.programId);
            protobuf.SetStreamId(update.streamId);
            bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
            variant.SetMessageValue(ProtobufUtil.ToByteArray(protobuf));
            field.SetKey(key);
            field.SetValue(variant);
            val.SetField(field);
            updateRequest.SetEntityId(base.m_battleNet.GameAccountId);
            updateRequest.AddFieldOperation(val);
        }
        this.PublishField(updateRequest);
    }
Example #2
0
        public void PublishRichPresence([In] RichPresenceUpdate[] updates)
        {
            UpdateRequest updateRequest = new UpdateRequest()
            {
                EntityId = this.m_battleNet.GameAccountId
            };
            FieldOperation fieldOperation = new FieldOperation();
            Field          field          = new Field();
            FieldKey       fieldKey       = new FieldKey();

            fieldKey.SetProgram(BnetProgramId.BNET.GetValue());
            fieldKey.SetGroup(2);
            fieldKey.SetField(8);
            RichPresenceUpdate[] richPresenceUpdateArray = updates;
            for (int i = 0; i < (int)richPresenceUpdateArray.Length; i++)
            {
                RichPresenceUpdate richPresenceUpdate = richPresenceUpdateArray[i];
                fieldKey.SetIndex(richPresenceUpdate.presenceFieldIndex);
                RichPresence richPresence = new RichPresence();
                richPresence.SetIndex(richPresenceUpdate.index);
                richPresence.SetProgramId(richPresenceUpdate.programId);
                richPresence.SetStreamId(richPresenceUpdate.streamId);
                bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
                variant.SetMessageValue(ProtobufUtil.ToByteArray(richPresence));
                field.SetKey(fieldKey);
                field.SetValue(variant);
                fieldOperation.SetField(field);
                updateRequest.SetEntityId(this.m_battleNet.GameAccountId);
                updateRequest.AddFieldOperation(fieldOperation);
            }
            this.PublishField(updateRequest);
        }