예제 #1
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 contentHandle = handles.ContentHandle.get_Item(0);
            if (contentHandle == null || !contentHandle.IsInitialized)
            {
                this.m_cmLogSource.LogWarning("The content handle received is not valid!");
                return;
            }
            this.m_cmLogSource.LogDebug("Received request to enable connection metering.");
            ContentHandle contentHandle2 = ContentHandle.FromProtocol(contentHandle);

            this.m_cmLogSource.LogDebug("Requesting file from local storage. ContentHandle={0}", new object[]
            {
                contentHandle2
            });
            localStorage.GetFile(contentHandle2, new LocalStorageAPI.DownloadCompletedCallback(this.DownloadCompletedCallback), null);
        }
예제 #2
0
        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)
            {
                base.ApiLog.LogWarning("Battle.net Resources API C#: Failed lookup. Error={0}", new object[]
                {
                    status
                });
                resourcesAPIPendingState.Callback(null, resourcesAPIPendingState.UserContext);
                return;
            }
            ContentHandle contentHandle2 = ContentHandle.FromProtocol(contentHandle);

            resourcesAPIPendingState.Callback(contentHandle2, resourcesAPIPendingState.UserContext);
        }