public void PublishRichPresence([In] RichPresenceUpdate[] updates) { UpdateRequest updateRequest = new UpdateRequest(); 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(2u); fieldKey.SetField(8u); foreach (RichPresenceUpdate richPresenceUpdate in updates) { fieldKey.SetIndex(richPresenceUpdate.presenceFieldIndex); RichPresence richPresence = new RichPresence(); richPresence.SetIndex(richPresenceUpdate.index); richPresence.SetProgramId(richPresenceUpdate.programId); richPresence.SetStreamId(richPresenceUpdate.streamId); Variant variant = new 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); }
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); }
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); }
private void HandleRichPresenceUpdate(PresenceUpdate rpUpdate, FieldKey fieldKey) { FieldKey fieldKey2 = new FieldKey(); fieldKey2.SetProgram(BnetProgramId.BNET.GetValue()); fieldKey2.SetGroup(2u); fieldKey2.SetField(8u); fieldKey2.SetIndex(0UL); if (!fieldKey2.Equals(fieldKey)) { return; } this.m_pendingRichPresenceUpdates.Add(rpUpdate); this.TryToResolveRichPresence(); }
private bool ResolveRichPresenceStrings(out string richPresenceString, bgs.types.EntityId entityId, ulong index, int recurseDepth) { richPresenceString = string.Empty; FieldKey fieldKey = new FieldKey(); fieldKey.SetProgram(BnetProgramId.BNET.GetValue()); fieldKey.SetGroup(2u); fieldKey.SetField(8u); fieldKey.SetIndex(index); Variant cache = this.m_presenceCache.GetCache(entityId, fieldKey); if (cache == null) { base.ApiLog.LogError("Expected field missing from presence cache when resolving rich presence string"); return(false); } RichPresence richPresence = RichPresence.ParseFrom(cache.MessageValue); if (richPresence == null || !richPresence.IsInitialized) { base.ApiLog.LogError("Rich presence field did not contain valid RichPresence message when resolving"); return(false); } if (!this.m_richPresenceStringTables.ContainsKey(richPresence)) { return(false); } PresenceAPI.IndexToStringMap indexToStringMap = this.m_richPresenceStringTables[richPresence]; if (!indexToStringMap.ContainsKey((ulong)richPresence.Index)) { base.ApiLog.LogWarning("Rich presence string table data is missing"); return(false); } richPresenceString = indexToStringMap[(ulong)richPresence.Index]; if (recurseDepth < 1 && !this.SubstituteVariables(out richPresenceString, richPresenceString, entityId, recurseDepth + 1)) { base.ApiLog.LogWarning("Failed to substitute rich presence variables in: {0}", new object[] { richPresenceString }); return(false); } return(true); }
public void RequestPresenceFields(bool isGameAccountEntityId, [In] bgs.types.EntityId entityId, [In] PresenceFieldKey[] fieldList) { QueryRequest queryRequest = new QueryRequest(); bnet.protocol.EntityId entityId1 = new bnet.protocol.EntityId(); entityId1.SetHigh(entityId.hi); entityId1.SetLow(entityId.lo); queryRequest.SetEntityId(entityId1); PresenceFieldKey[] presenceFieldKeyArray = fieldList; for (int i = 0; i < (int)presenceFieldKeyArray.Length; i++) { PresenceFieldKey presenceFieldKey = presenceFieldKeyArray[i]; FieldKey fieldKey = new FieldKey(); fieldKey.SetProgram(presenceFieldKey.programId); fieldKey.SetGroup(presenceFieldKey.groupId); fieldKey.SetField(presenceFieldKey.fieldId); fieldKey.SetIndex(presenceFieldKey.index); queryRequest.AddKey(fieldKey); } this.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 4, queryRequest, (RPCContext context) => this.RequestPresenceFieldsCallback(new bgs.types.EntityId(entityId), context), 0); }
public void RequestPresenceFields(bool isGameAccountEntityId, [In] bgs.types.EntityId entityId, [In] PresenceFieldKey[] fieldList) { QueryRequest queryRequest = new QueryRequest(); bnet.protocol.EntityId entityId2 = new bnet.protocol.EntityId(); entityId2.SetHigh(entityId.hi); entityId2.SetLow(entityId.lo); queryRequest.SetEntityId(entityId2); foreach (PresenceFieldKey presenceFieldKey in fieldList) { FieldKey fieldKey = new FieldKey(); fieldKey.SetProgram(presenceFieldKey.programId); fieldKey.SetGroup(presenceFieldKey.groupId); fieldKey.SetField(presenceFieldKey.fieldId); fieldKey.SetIndex(presenceFieldKey.index); queryRequest.AddKey(fieldKey); } this.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 4u, queryRequest, delegate(RPCContext context) { this.RequestPresenceFieldsCallback(new bgs.types.EntityId(entityId), context); }, 0u); }