private void GetContentHandleCallback(RPCContext context)
        {
            ResourcesAPIPendingState resourcesAPIPendingState = null;

            if (!this.m_pendingLookups.TryGetValue(context.Header.Token, out resourcesAPIPendingState))
            {
                base.ApiLog.LogWarning("Received unmatched lookup response");
                return;
            }
            this.m_pendingLookups.Remove(context.Header.Token);
            bnet.protocol.ContentHandle contentHandle = bnet.protocol.ContentHandle.ParseFrom(context.Payload);
            if (contentHandle == null || !contentHandle.IsInitialized)
            {
                base.ApiLog.LogWarning("Received invalid response");
                resourcesAPIPendingState.Callback(null, resourcesAPIPendingState.UserContext);
                return;
            }
            BattleNetErrors status = (BattleNetErrors)context.Header.Status;

            if (status == BattleNetErrors.ERROR_OK)
            {
                bgs.ContentHandle contentHandle1 = bgs.ContentHandle.FromProtocol(contentHandle);
                resourcesAPIPendingState.Callback(contentHandle1, resourcesAPIPendingState.UserContext);
                return;
            }
            base.ApiLog.LogWarning("Battle.net Resources API C#: Failed lookup. Error={0}", new object[] { status });
            resourcesAPIPendingState.Callback(null, resourcesAPIPendingState.UserContext);
        }
Exemple #2
0
 private void ResouceLookupCallback(bgs.ContentHandle contentHandle, object userContext)
 {
     if (contentHandle == null)
     {
         base.ApiLog.LogWarning("BN resource look up failed unable to proceed");
         this.DecrementOutstandingRichPresenceStringFetches();
         return;
     }
     base.ApiLog.LogDebug("Lookup done Region={0} Usage={1} SHA256={2}", new object[] { contentHandle.Region, contentHandle.Usage, contentHandle.Sha256Digest });
     this.m_battleNet.LocalStorage.GetFile(contentHandle, new LocalStorageAPI.DownloadCompletedCallback(this.DownloadCompletedCallback), userContext);
 }
        private void ResouceLookupTestCallback(bgs.ContentHandle contentHandle, object userContext)
        {
            if (contentHandle == null)
            {
                base.ApiLog.LogWarning("Lookup failed");
                return;
            }
            int num = (int)userContext;

            base.ApiLog.LogDebug("Lookup done i={0} Region={1} Usage={2} SHA256={3}", new object[] { num, contentHandle.Region, contentHandle.Usage, contentHandle.Sha256Digest });
        }
 public static bgs.ContentHandle FromProtocol(bnet.protocol.ContentHandle contentHandle)
 {
     if (contentHandle == null || !contentHandle.IsInitialized)
     {
         return(null);
     }
     bgs.ContentHandle contentHandle1 = new bgs.ContentHandle()
     {
         Region       = (new FourCC(contentHandle.Region)).ToString(),
         Usage        = (new FourCC(contentHandle.Usage)).ToString(),
         Sha256Digest = bgs.ContentHandle.ByteArrayToString(contentHandle.Hash)
     };
     return(contentHandle1);
 }
Exemple #5
0
 public void SetConnectionMeteringContentHandles(ConnectionMeteringContentHandles handles, LocalStorageAPI localStorage)
 {
     if (handles == null || !handles.IsInitialized || handles.ContentHandleCount == 0)
     {
         this.m_cmLogSource.LogWarning("Invalid connection metering content handle received.");
         return;
     }
     if (handles.ContentHandleCount != 1)
     {
         this.m_cmLogSource.LogWarning("More than 1 connection metering content handle specified!");
     }
     bnet.protocol.ContentHandle item = handles.ContentHandle[0];
     if (item == null || !item.IsInitialized)
     {
         this.m_cmLogSource.LogWarning("The content handle received is not valid!");
         return;
     }
     this.m_cmLogSource.LogDebug("Received request to enable connection metering.");
     bgs.ContentHandle contentHandle = bgs.ContentHandle.FromProtocol(item);
     this.m_cmLogSource.LogDebug("Requesting file from local storage. ContentHandle={0}", new object[] { contentHandle });
     localStorage.GetFile(contentHandle, new LocalStorageAPI.DownloadCompletedCallback(this.DownloadCompletedCallback), null);
 }