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 SetPresenceBlob(uint field, byte[] val) { UpdateRequest updateRequest = new UpdateRequest(); updateRequest.EntityId = this.m_battleNet.GameAccountId; FieldOperation fieldOperation = new FieldOperation(); Field field2 = new Field(); FieldKey fieldKey = new FieldKey(); fieldKey.SetProgram(BnetProgramId.WOW.GetValue()); fieldKey.SetGroup(2u); fieldKey.SetField(field); Variant variant = new Variant(); if (val == null) { val = new byte[0]; } variant.SetBlobValue(val); field2.SetKey(fieldKey); field2.SetValue(variant); fieldOperation.SetField(field2); updateRequest.SetEntityId(this.m_battleNet.GameAccountId); updateRequest.AddFieldOperation(fieldOperation); 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 SetPresenceBool(uint field, bool val) { UpdateRequest updateRequest = new UpdateRequest(); FieldOperation fieldOperation = new FieldOperation(); Field field1 = new Field(); FieldKey fieldKey = new FieldKey(); fieldKey.SetProgram(BnetProgramId.WOW.GetValue()); fieldKey.SetGroup(2); fieldKey.SetField(field); bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant(); variant.SetBoolValue(val); field1.SetKey(fieldKey); field1.SetValue(variant); fieldOperation.SetField(field1); updateRequest.SetEntityId(this.m_battleNet.GameAccountId); updateRequest.AddFieldOperation(fieldOperation); this.PublishField(updateRequest); }
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); }
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); }
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 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); }