public void NotifyMethodListener(RPCContext context) { if (this.Methods != null && context.Header.MethodId > 0u && (ulong)context.Header.MethodId <= (ulong)((long)this.Methods.Length)) { this.Methods[(int)((UIntPtr)context.Header.MethodId)].NotifyListener(context); } }
public void NotifyListener(RPCContext context) { if (this.listener != null) { this.listener(context); } }
private void HandleChannelSubscriber_NotifyJoin(RPCContext context) { JoinNotification joinNotification = JoinNotification.ParseFrom(context.Payload); base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyJoin: " + joinNotification); ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId); if (channelReferenceObject == null) { base.ApiLog.LogError("HandleChannelSubscriber_NotifyJoin had unexpected traffic for objectId : " + context.Header.ObjectId); return; } ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType; switch (channelType) { case ChannelAPI.ChannelType.PRESENCE_CHANNEL: goto IL_103; } ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData; if (channelData != null) { EntityId gameAccountId = joinNotification.Member.Identity.GameAccountId; channelData.m_members.Add(gameAccountId, joinNotification.Member); if (!this.m_battleNet.GameAccountId.Equals(gameAccountId)) { this.m_battleNet.Presence.PresenceSubscribe(joinNotification.Member.Identity.GameAccountId); } } IL_103: if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL) { this.m_battleNet.Party.PartyMemberJoined(channelReferenceObject, joinNotification); } }
private void HandleChannelSubscriber_NotifyLeave(RPCContext context) { LeaveNotification leaveNotification = LeaveNotification.ParseFrom(context.Payload); base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyLeave: " + leaveNotification); ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId); if (channelReferenceObject == null) { base.ApiLog.LogError("HandleChannelSubscriber_NotifyLeave had unexpected traffic for objectId : " + context.Header.ObjectId); return; } switch (channelReferenceObject.m_channelData.m_channelType) { case ChannelAPI.ChannelType.CHAT_CHANNEL: case ChannelAPI.ChannelType.GAME_CHANNEL: break; case ChannelAPI.ChannelType.PARTY_CHANNEL: this.m_battleNet.Party.PartyMemberLeft(channelReferenceObject, leaveNotification); break; default: return; } ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData; if (channelData != null) { channelData.m_members.Remove(leaveNotification.MemberId); if (!this.m_battleNet.GameAccountId.Equals(leaveNotification.MemberId)) { this.m_battleNet.Presence.PresenceUnsubscribe(leaveNotification.MemberId); } } }
private void HandleLogonCompleteRequest(RPCContext context) { LogonResult logonResult = LogonResult.ParseFrom(context.Payload); BattleNetErrors errorCode = (BattleNetErrors)logonResult.ErrorCode; if (errorCode != BattleNetErrors.ERROR_OK) { this.m_battleNet.EnqueueErrorInfo(BnetFeature.Auth, BnetFeatureEvent.Auth_OnFinish, errorCode, 0); return; } this.m_accountEntity = logonResult.Account; this.m_battleNet.Presence.PresenceSubscribe(this.m_accountEntity); this.m_gameAccounts = new List <bnet.protocol.EntityId>(); foreach (bnet.protocol.EntityId gameAccountList in logonResult.GameAccountList) { this.m_gameAccounts.Add(gameAccountList); this.m_battleNet.Presence.PresenceSubscribe(gameAccountList); } if (logonResult.HasBattleTag) { this.m_battleTag = logonResult.BattleTag; } if (this.m_gameAccounts.Count > 0) { this.m_gameAccount = logonResult.GameAccountList[0]; } this.m_sessionKey = logonResult.SessionKey; this.m_battleNet.IssueSelectGameAccountRequest(); this.m_battleNet.SetConnectedRegion(logonResult.ConnectedRegion); base.ApiLog.LogDebug("LogonComplete {0}", new object[] { logonResult }); base.ApiLog.LogDebug("Region (connected): {0}", new object[] { logonResult.ConnectedRegion }); }
private void HandleChannelInvitation_NotifyReceivedSuggestionAdded(RPCContext context) { SuggestionAddedNotification suggestionAddedNotification = SuggestionAddedNotification.ParseFrom(context.Payload); EntityId entityId = (!suggestionAddedNotification.Suggestion.HasChannelId) ? null : suggestionAddedNotification.Suggestion.ChannelId; ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(entityId); if (channelReferenceObject == null) { base.ApiLog.LogError("HandleChannelInvitation_NotifyReceivedSuggestionAdded had unexpected traffic for channelId: " + entityId); return; } base.ApiLog.LogDebug("HandleChannelInvitation_NotifyReceivedSuggestionAdded: " + suggestionAddedNotification); if (this.m_receivedInviteRequests == null) { this.m_receivedInviteRequests = new Map <EntityId, List <Suggestion> >(); } List <Suggestion> list; if (!this.m_receivedInviteRequests.TryGetValue(entityId, out list)) { list = new List <Suggestion>(); this.m_receivedInviteRequests[entityId] = list; } if (list.IndexOf(suggestionAddedNotification.Suggestion) < 0) { list.Add(suggestionAddedNotification.Suggestion); } ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType; if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL) { this.m_battleNet.Party.ReceivedInviteRequestDelta(entityId, suggestionAddedNotification.Suggestion, default(uint?)); } }
private void HandleAccountNotify_AccountStateUpdated(RPCContext context) { if (context == null || context.Payload == null) { base.ApiLog.LogWarning("HandleAccountNotify_AccountStateUpdated invalid context!"); return; } AccountStateNotification accountStateNotification = AccountStateNotification.ParseFrom(context.Payload); if (accountStateNotification == null || !accountStateNotification.IsInitialized) { base.ApiLog.LogWarning("HandleAccountNotify_AccountStateUpdated unable to parse response!"); return; } if (!accountStateNotification.HasState) { base.ApiLog.LogDebug("HandleAccountNotify_AccountStateUpdated HasState=false, data={0}", new object[] { accountStateNotification }); return; } AccountState state = accountStateNotification.State; if (!state.HasAccountLevelInfo) { base.ApiLog.LogDebug("HandleAccountNotify_AccountStateUpdated HasAccountLevelInfo=false, data={0}", new object[] { accountStateNotification }); return; } if (!state.AccountLevelInfo.HasPreferredRegion) { base.ApiLog.LogDebug("HandleAccountNotify_AccountStateUpdated HasPreferredRegion=false, data={0}", new object[] { accountStateNotification }); return; } base.ApiLog.LogDebug("HandleAccountNotify_AccountStateUpdated, data={0}", new object[] { accountStateNotification }); }
public void QueueResponse(RPCContext context, IProtoBuf message) { if (message == null || context.Header == null) { this.m_logSource.LogError("QueueResponse: invalid response"); return; } if (this.serviceHelper.GetImportedServiceById(context.Header.ServiceId) == null) { this.m_logSource.LogError("QueueResponse: error, unrecognized service id: " + context.Header.ServiceId); return; } this.m_logSource.LogDebug(string.Concat(new object[] { "QueueResponse: type=", this.serviceHelper.GetImportedServiceById(context.Header.ServiceId).GetMethodName(context.Header.MethodId), " data=", message })); Header header = context.Header; header.SetServiceId(254u); header.SetMethodId(0u); header.SetSize(message.GetSerializedSize()); context.Header = header; BattleNetPacket packet = new BattleNetPacket(context.Header, message); this.QueuePacket(packet); }
private void UtilClientRequestCallback(RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { this.m_battleNet.EnqueueErrorInfo(BnetFeature.Games, BnetFeatureEvent.Games_OnClientRequest, status, 0); return; } ClientResponse clientResponse = ClientResponse.ParseFrom(context.Payload); if (clientResponse.AttributeCount >= 2) { bnet.protocol.attribute.Attribute attribute = clientResponse.AttributeList[0]; bnet.protocol.attribute.Attribute attribute2 = clientResponse.AttributeList[1]; if (!attribute.Value.HasIntValue || !attribute2.Value.HasBlobValue) { base.ApiLog.LogError("Malformed Attribute in Util Packet: incorrect values"); } this.m_utilPackets.Enqueue(new GamesAPI.UtilResponse(clientResponse, context.Context)); } else { base.ApiLog.LogError("Malformed Attribute in Util Packet: missing values"); } }
public void CancelGameCallback(RPCContext context) { BattleNetCSharp battleNetCSharp = BattleNet.Get() as BattleNetCSharp; if (battleNetCSharp == null || battleNetCSharp.Games == null) { return; } BattleNetErrors status = (BattleNetErrors)context.Header.Status; battleNetCSharp.Games.ApiLog.LogDebug("CancelGameCallback, status=" + status); if (status == BattleNetErrors.ERROR_OK || status == BattleNetErrors.ERROR_GAME_MASTER_INVALID_GAME) { if (battleNetCSharp.Games.IsFindGamePending || (battleNetCSharp.Games.CurrentGameRequest != 0UL && battleNetCSharp.Games.CurrentGameRequest != this.m_gameRequestId)) { battleNetCSharp.Games.ApiLog.LogDebug("CancelGameCallback received for id={0} but is not the current gameRequest={1}, ignoring it.", new object[] { this.m_gameRequestId, battleNetCSharp.Games.CurrentGameRequest }); } else { battleNetCSharp.Games.CurrentGameRequest = 0UL; battleNetCSharp.Games.AddQueueEvent(QueueEvent.Type.QUEUE_CANCEL, 0, 0, 0, null); } } else { battleNetCSharp.EnqueueErrorInfo(BnetFeature.Games, BnetFeatureEvent.Games_OnCancelGame, status, 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); }
public void LookupResource(FourCC programId, FourCC streamId, FourCC locale, ResourcesAPI.ResourceLookupCallback cb, object userContext) { ContentHandleRequest contentHandleRequest = new ContentHandleRequest(); contentHandleRequest.SetProgramId(programId.GetValue()); contentHandleRequest.SetStreamId(streamId.GetValue()); contentHandleRequest.SetLocale(locale.GetValue()); if (contentHandleRequest == null || !contentHandleRequest.IsInitialized) { base.ApiLog.LogWarning("Unable to create request for RPC call."); return; } RPCContext rPCContext = this.m_rpcConnection.QueueRequest(this.m_resourcesService.Id, 1u, contentHandleRequest, new RPCContextDelegate(this.GetContentHandleCallback), 0u); ResourcesAPIPendingState resourcesAPIPendingState = new ResourcesAPIPendingState(); resourcesAPIPendingState.Callback = cb; resourcesAPIPendingState.UserContext = userContext; this.m_pendingLookups.Add(rPCContext.Header.Token, resourcesAPIPendingState); base.ApiLog.LogDebug("Lookup request sent. PID={0} StreamID={1} Locale={2}", new object[] { programId, streamId, locale }); }
private void HandleForceDisconnectRequest(RPCContext context) { DisconnectNotification disconnectNotification = DisconnectNotification.ParseFrom(context.Payload); this.m_logSource.LogDebug("RPC Called: ForceDisconnect : " + disconnectNotification.ErrorCode); this.EnqueueErrorInfo(BnetFeature.Bnet, BnetFeatureEvent.Bnet_OnDisconnected, (BattleNetErrors)disconnectNotification.ErrorCode, 0); }
public void PresenceUnsubscribeCallback(RPCContext context) { if (this.m_battleNet.Presence.CheckRPCCallback("PresenceUnsubscribeCallback", context)) { this.m_battleNet.Channel.RemoveActiveChannel(this.m_objectId); } }
private void NotifyFriendRemovedListenerCallback(RPCContext context) { if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED) { return; } this.RemoveFriendInternal(this.ExtractEntityIdFromFriendNotification(context.Payload)); }
private void HandleLogonQueueUpdate(RPCContext context) { LogonQueueUpdateRequest logonQueueUpdateRequest = LogonQueueUpdateRequest.ParseFrom(context.Payload); base.ApiLog.LogDebug(string.Concat("HandleLogonQueueUpdate : ", logonQueueUpdateRequest.ToString())); long estimatedTime = (long)((logonQueueUpdateRequest.EstimatedTime - this.m_battleNet.ServerTimeUTCAtConnectMicroseconds) / (long)1000000); this.SaveQueuePosition((int)logonQueueUpdateRequest.Position, estimatedTime, (long)logonQueueUpdateRequest.EtaDeviationInSec, false); }
private void NotifyReceivedInvitationRemovedCallback(RPCContext context) { if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED) { return; } Invitation invitation = this.ExtractInvitationFromInvitationNotification(context.Payload); this.AddInvitationInternal(FriendsUpdate.Action.FRIEND_INVITE_REMOVED, invitation, 0); }
private void NotifyFriendAddedListenerCallback(RPCContext context) { if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED) { return; } BnetEntityId entityId = this.ExtractEntityIdFromFriendNotification(context.Payload); this.AddFriendInternal(entityId); }
private void WhisperSentCallback(RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { base.ApiLog.LogWarning("Battle.net Whisper API C#: Failed to SendWhisper. " + status); this.m_battleNet.EnqueueErrorInfo(BnetFeature.Whisper, BnetFeatureEvent.Whisper_OnSend, status, context.Context); } }
public void NotifyMethodListener(RPCContext context) { unsafe { if (this.Methods != null && context.Header.MethodId > 0 && (ulong)context.Header.MethodId <= (long)((int)this.Methods.Length)) { this.Methods[context.Header.MethodId].NotifyListener(context); } } }
private void SubscribeToAccountServiceCallback(RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { base.ApiLog.LogError("SubscribeToAccountServiceCallback: " + status.ToString()); return; } base.ApiLog.LogDebug("SubscribeToAccountServiceCallback, status=" + status.ToString()); }
public bool CheckRPCCallback(string name, RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; BattleNetAPI.LogDelegate mLogDelegates = this.m_logDelegates[(status != BattleNetErrors.ERROR_OK ? 1 : 0)]; object[] objArray = new object[] { status, null, null }; objArray[1] = (!string.IsNullOrEmpty(name) ? name : "<null>"); objArray[2] = (context.Request == null ? "<null>" : context.Request.ToString()); mLogDelegates("Callback invoked, status = {0}, name = {1}, request = {2}", objArray); return(status == BattleNetErrors.ERROR_OK); }
private void GetAccountStateCallback(RPCContext context) { if (context == null || context.Payload == null) { base.ApiLog.LogWarning("GetAccountLevelInfo invalid context!"); return; } BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { base.ApiLog.LogError("GetAccountLevelInfo failed with error={0}", new object[] { status.ToString() }); return; } GetAccountStateResponse getAccountStateResponse = GetAccountStateResponse.ParseFrom(context.Payload); if (getAccountStateResponse == null || !getAccountStateResponse.IsInitialized) { base.ApiLog.LogWarning("GetAccountStateCallback unable to parse response!"); return; } if (!getAccountStateResponse.HasState || !getAccountStateResponse.State.HasAccountLevelInfo) { base.ApiLog.LogWarning("GetAccountStateCallback response has no data!"); return; } GetAccountStateRequest request = (GetAccountStateRequest)context.Request; if (request != null && request.EntityId == this.m_battleNet.AccountId) { AccountLevelInfo accountLevelInfo = getAccountStateResponse.State.AccountLevelInfo; this.m_preferredRegion = accountLevelInfo.PreferredRegion; this.m_accountCountry = accountLevelInfo.Country; base.ApiLog.LogDebug("Region (preferred): {0}", new object[] { this.m_preferredRegion }); base.ApiLog.LogDebug("Country (account): {0}", new object[] { this.m_accountCountry }); if (accountLevelInfo.LicensesList.Count <= 0) { base.ApiLog.LogWarning("No licenses found!"); } else { this.m_licenses.Clear(); base.ApiLog.LogDebug("Found {0} licenses.", new object[] { accountLevelInfo.LicensesList.Count }); for (int i = 0; i < accountLevelInfo.LicensesList.Count; i++) { AccountLicense item = accountLevelInfo.LicensesList[i]; this.m_licenses.Add(item); base.ApiLog.LogDebug("Adding license id={0}", new object[] { item.Id }); } } } base.ApiLog.LogDebug(string.Concat("GetAccountLevelInfo, status=", status.ToString())); }
public bool CheckRPCCallback(string name, RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; int num = (status != BattleNetErrors.ERROR_OK) ? 1 : 0; this.m_logDelegates[num]("Callback invoked, status = {0}, name = {1}, request = {2}", new object[] { status, (!string.IsNullOrEmpty(name)) ? name : "<null>", (context.Request == null) ? "<null>" : context.Request.ToString() }); return(status == BattleNetErrors.ERROR_OK); }
private void GetAllValuesForAttributeCallback(RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { this.m_battleNet.EnqueueErrorInfo(BnetFeature.Games, BnetFeatureEvent.Games_OnGetAllValuesForAttribute, status, 0); return; } GetAllValuesForAttributeResponse response = ProtobufUtil.ParseFrom <GetAllValuesForAttributeResponse>(context.Payload, 0, -1); this.m_getAllValuesForAttributeResults.Enqueue(new GamesAPI.GetAllValuesForAttributeResult(response, context.Context)); }
private void RemoveFriendCallback(RPCContext context) { if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED) { return; } BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { base.ApiLog.LogWarning("Battle.net Friends API C#: Failed to RemoveFriend. " + status); this.m_battleNet.EnqueueErrorInfo(BnetFeature.Friends, BnetFeatureEvent.Friends_OnRemoveFriend, status, 0); } }
public void GetAllValuesForAttribute(string attributeKey, int context) { GetAllValuesForAttributeRequest getAllValuesForAttributeRequest = new GetAllValuesForAttributeRequest(); getAllValuesForAttributeRequest.AttributeKey = attributeKey; if (this.m_rpcConnection == null) { base.ApiLog.LogError("GetAllValuesForAttribute could not send, connection not valid : " + getAllValuesForAttributeRequest.ToString()); return; } RPCContext rpccontext = this.m_rpcConnection.QueueRequest(this.m_gameUtilitiesService.Id, 10u, getAllValuesForAttributeRequest, new RPCContextDelegate(this.GetAllValuesForAttributeCallback), 0u); rpccontext.Context = context; }
private void AcceptInvitationCallback(RPCContext context) { if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED) { return; } BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { base.ApiLog.LogWarning(string.Concat("Battle.net Friends API C#: Failed to AcceptInvitation. ", status)); this.m_battleNet.EnqueueErrorInfo(BnetFeature.Friends, BnetFeatureEvent.Friends_OnAcceptInvitation, status, 0); } }
public void JoinChannelCallback(RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { this.m_channelAPI.ApiLog.LogError("JoinChannelCallback: " + status.ToString()); return; } JoinChannelResponse joinChannelResponse = JoinChannelResponse.ParseFrom(context.Payload); base.SetObjectId(joinChannelResponse.ObjectId); this.m_channelAPI.AddActiveChannel(this.m_subscriberObjectId, new ChannelAPI.ChannelReferenceObject(this)); this.m_channelAPI.ApiLog.LogDebug("JoinChannelCallback, status=" + status.ToString()); }
private void HandleNotificationReceived(RPCContext context) { Notification notification = Notification.ParseFrom(context.Payload); this.m_logSource.LogDebug("Notification: " + notification); BattleNetCSharp.NotificationHandler notificationHandler; if (this.m_notificationHandlers.TryGetValue(notification.Type, out notificationHandler)) { notificationHandler(notification); } else { this.m_logSource.LogWarning("unhandled battle net notification: " + notification.Type); } }