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."); } else { if (handles.ContentHandleCount != 1) { this.m_cmLogSource.LogWarning("More than 1 connection metering content handle specified!"); } bnet.protocol.ContentHandle contentHandle = handles.ContentHandle[0]; if ((contentHandle == null) || !contentHandle.IsInitialized) { this.m_cmLogSource.LogWarning("The content handle received is not valid!"); } else { this.m_cmLogSource.LogDebug("Received request to enable connection metering."); ContentHandle ch = ContentHandle.FromProtocol(contentHandle); object[] args = new object[] { ch }; this.m_cmLogSource.LogDebug("Requesting file from local storage. ContentHandle={0}", args); localStorage.GetFile(ch, new LocalStorageAPI.DownloadCompletedCallback(this.DownloadCompletedCallback)); } } }
private void GetContentHandleCallback(RPCContext context) { ResourcesAPIPendingState state = null; if (!this.m_pendingLookups.TryGetValue(context.Header.Token, out state)) { base.ApiLog.LogWarning("Received unmatched lookup response"); } else { 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"); state.Callback(null, state.UserContext); } else { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { object[] args = new object[] { status }; base.ApiLog.LogWarning("Battle.net Resources API C#: Failed lookup. Error={0}", args); state.Callback(null, state.UserContext); } else { ContentHandle handle2 = ContentHandle.FromProtocol(contentHandle); state.Callback(handle2, state.UserContext); } } } }