public static KeyValuePair <string, object>[] GetAllPartyAttributes(PartyId partyId) { if (partyId == null) { return(new KeyValuePair <string, object> [0]); } string[] array; BattleNet.GetAllPartyAttributes(partyId.ToEntityId(), out array); KeyValuePair <string, object>[] array2 = new KeyValuePair <string, object> [array.Length]; for (int i = 0; i < array2.Length; i++) { string text = array[i]; object value = null; long? partyAttributeLong = BnetParty.GetPartyAttributeLong(partyId, text); if (partyAttributeLong != null) { value = partyAttributeLong; } string partyAttributeString = BnetParty.GetPartyAttributeString(partyId, text); if (partyAttributeString != null) { value = partyAttributeString; } byte[] partyAttributeBlob = BnetParty.GetPartyAttributeBlob(partyId, text); if (partyAttributeBlob != null) { value = partyAttributeBlob; } array2[i] = new KeyValuePair <string, object>(text, value); } return(array2); }
private static List <SslCertBundle> DownloadCertBundles(UrlDownloaderConfig dlConfig) { List <SslCertBundle> sslCertBundles = new List <SslCertBundle>(); List <string> strs = new List <string>(); if (BattleNet.Client().GetMobileEnvironment() != constants.MobileEnv.PRODUCTION) { strs.Add("http://nydus-qa.web.blizzard.net/Bnet/zxx/client/bgs-key-fingerprint"); } strs.Add("http://nydus.battle.net/Bnet/zxx/client/bgs-key-fingerprint"); IUrlDownloader urlDownloader = BattleNet.Client().GetUrlDownloader(); int count = strs.Count; foreach (string str in strs) { urlDownloader.Download(str, (bool success, byte[] bytes) => { if (success) { SslCertBundle sslCertBundle = new SslCertBundle(bytes); sslCertBundles.Add(sslCertBundle); } count--; }, dlConfig); } while (count > 0) { Thread.Sleep(15); } return(sslCertBundles); }
public static Variant GetPartyAttributeVariant(PartyId partyId, string attributeKey) { Variant variant = new Variant(); EntityId partyId2 = partyId.ToEntityId(); long intValue; if (BattleNet.GetPartyAttributeLong(partyId2, attributeKey, out intValue)) { variant.IntValue = intValue; } else { string text; BattleNet.GetPartyAttributeString(partyId2, attributeKey, out text); if (text != null) { variant.StringValue = text; } else { byte[] array; BattleNet.GetPartyAttributeBlob(partyId2, attributeKey, out array); if (array != null) { variant.BlobValue = array; } } } return(variant); }
public void SendWhisper(BnetGameAccountId gameAccount, string message) { if (string.IsNullOrEmpty(message)) { return; } Notification notification = new Notification(); notification.SetType("WHISPER"); bnet.protocol.EntityId entityId = new bnet.protocol.EntityId(); entityId.SetLow(gameAccount.GetLo()); entityId.SetHigh(gameAccount.GetHi()); notification.SetTargetId(entityId); Attribute attribute = new Attribute(); attribute.SetName("whisper"); Variant variant = new Variant(); variant.SetStringValue(message); attribute.SetValue(variant); notification.AddAttribute(attribute); this.m_rpcConnection.QueueRequest(this.m_battleNet.NotificationService.Id, 1u, notification, new RPCContextDelegate(this.WhisperSentCallback), 0u); BnetGameAccountId speakerId = BnetGameAccountId.CreateFromEntityId(BattleNet.GetMyGameAccountId()); BnetWhisper bnetWhisper = new BnetWhisper(); bnetWhisper.SetSpeakerId(speakerId); bnetWhisper.SetReceiverId(gameAccount); bnetWhisper.SetMessage(message); bnetWhisper.SetTimestampMilliseconds(TimeUtils.GetElapsedTimeSinceEpoch(default(DateTime?)).get_TotalMilliseconds()); this.m_whispers.Add(bnetWhisper); }
private bool FetchRichPresenceResource(Variant presenceValue) { if (presenceValue == null) { return(false); } RichPresence richPresence = RichPresence.ParseFrom(presenceValue.MessageValue); if (richPresence == null || !richPresence.IsInitialized) { base.ApiLog.LogError("Rich presence field from battle.net does not contain valid RichPresence message"); return(false); } if (this.m_richPresenceStringTables.ContainsKey(richPresence)) { return(false); } FourCC programId = new FourCC(richPresence.ProgramId); FourCC streamId = new FourCC(richPresence.StreamId); FourCC locale = new FourCC(BattleNet.Client().GetLocaleName()); this.IncrementOutstandingRichPresenceStringFetches(); ResourcesAPI resources = this.m_battleNet.Resources; resources.LookupResource(programId, streamId, locale, new ResourcesAPI.ResourceLookupCallback(this.ResouceLookupCallback), richPresence); return(true); }
public void ResetStartupPeriod() { if (this.m_data != null) { this.m_data.StartupPeriodEnd = (float)BattleNet.GetRealTimeSinceStartup() + this.m_data.StartupPeriodDuration; } }
private static string MakeFullPathFromState(LocalStorageFileState state) { string temporaryCachePath = BattleNet.Client().GetTemporaryCachePath(); string text = state.CH.Sha256Digest + "." + state.CH.Usage; return(Path.Combine(temporaryCachePath, text)); }
public static void RevokeSentInvite(PartyId partyId, ulong inviteId) { if (!BnetParty.IsInParty(partyId)) { return; } BattleNet.RevokePartyInvite(partyId.ToEntityId(), inviteId); }
public static int CountMembers(PartyId partyId) { if (partyId == null) { return(0); } return(BattleNet.GetCountPartyMembers(partyId.ToEntityId())); }
public static PrivacyLevel GetPrivacyLevel(PartyId partyId) { if (partyId == null) { return(PrivacyLevel.CLOSED); } return((PrivacyLevel)BattleNet.GetPartyPrivacy(partyId.ToEntityId())); }
public override void Process() { base.Process(); if (this.m_state == FriendsAPI.FriendsAPIState.INITIALIZING && BattleNet.GetRealTimeSinceStartup() - this.m_subscribeStartTime >= (double)this.InitializeTimeOut) { this.m_state = FriendsAPI.FriendsAPIState.FAILED_TO_INITIALIZE; base.ApiLog.LogWarning("Battle.net Friends API C#: Initialize timed out."); } }
public static void SetPrivacy(PartyId partyId, PrivacyLevel privacyLevel) { if (!BnetParty.IsInParty(partyId)) { return; } EntityId partyId2 = partyId.ToEntityId(); BattleNet.SetPartyPrivacy(partyId2, (int)privacyLevel); }
public static void DissolveParty(PartyId partyId) { if (!BnetParty.IsInParty(partyId)) { return; } EntityId partyId2 = partyId.ToEntityId(); BattleNet.DissolveParty(partyId2); }
public static byte[] GetPartyAttributeBlob(PartyId partyId, string attributeKey) { if (partyId == null) { return(null); } byte[] result; BattleNet.GetPartyAttributeBlob(partyId.ToEntityId(), attributeKey, out result); return(result); }
public static InviteRequest[] GetInviteRequests(PartyId partyId) { if (partyId == null) { return(new InviteRequest[0]); } InviteRequest[] result; BattleNet.GetPartyInviteRequests(partyId.ToEntityId(), out result); return(result); }
public static PartyInvite[] GetSentInvites(PartyId partyId) { if (partyId == null) { return(new PartyInvite[0]); } PartyInvite[] result; BattleNet.GetPartySentInvites(partyId.ToEntityId(), out result); return(result); }
public static void SendInvite(PartyId toWhichPartyId, BnetGameAccountId recipientId) { if (!BnetParty.IsInParty(toWhichPartyId)) { return; } EntityId partyId = toWhichPartyId.ToEntityId(); EntityId inviteeId = BnetEntityId.CreateEntityId(recipientId); BattleNet.SendPartyInvite(partyId, inviteeId, false); }
public static string GetPartyAttributeString(PartyId partyId, string attributeKey) { if (partyId == null) { return(null); } string result; BattleNet.GetPartyAttributeString(partyId.ToEntityId(), attributeKey, out result); return(result); }
private void StartInitialize() { this.m_subscribeStartTime = BattleNet.GetRealTimeSinceStartup(); this.m_state = FriendsAPI.FriendsAPIState.INITIALIZING; this.m_maxFriends = 0; this.m_maxReceivedInvitations = 0; this.m_maxSentInvitations = 0; this.m_friendsCount = 0; this.m_updateList = new List <FriendsUpdate>(); this.m_friendEntityId = new Map <BnetEntityId, Map <ulong, bnet.protocol.EntityId> >(); }
public static string GetBundleStoragePath() { string basePersistentDataPath = BattleNet.Client().GetBasePersistentDataPath(); if (!basePersistentDataPath.EndsWith("/")) { basePersistentDataPath = string.Concat(basePersistentDataPath, "/"); } basePersistentDataPath = string.Concat(basePersistentDataPath, "dlcertbundle"); return(basePersistentDataPath); }
public static bool IsPartyFull(PartyId partyId, bool includeInvites = true) { if (partyId == null) { return(false); } int num = BnetParty.CountMembers(partyId); int num2 = (!includeInvites) ? 0 : BnetParty.GetSentInvites(partyId).Length; int maxPartyMembers = BattleNet.GetMaxPartyMembers(partyId.ToEntityId()); return(num + num2 >= maxPartyMembers); }