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); }
public static void IgnoreInviteRequest(PartyId partyId, BnetGameAccountId requestedTargetId) { EntityId partyId2 = partyId.ToEntityId(); EntityId requestedTargetId2 = BnetEntityId.CreateEntityId(requestedTargetId); BattleNet.IgnoreInviteRequest(partyId2, requestedTargetId2); }
public void OnWhisper(Notification notification) { if (!notification.HasSenderId) { return; } if (notification.AttributeCount <= 0) { return; } BnetWhisper bnetWhisper = new BnetWhisper(); bnetWhisper.SetSpeakerId(BnetGameAccountId.CreateFromProtocol(notification.SenderId)); bnetWhisper.SetReceiverId(BnetGameAccountId.CreateFromProtocol(notification.TargetId)); for (int i = 0; i < notification.AttributeCount; i++) { Attribute attribute = notification.Attribute.get_Item(i); if (attribute.Name == "whisper") { bnetWhisper.SetMessage(attribute.Value.StringValue); } } if (string.IsNullOrEmpty(bnetWhisper.GetMessage())) { return; } bnetWhisper.SetTimestampMilliseconds(TimeUtils.GetElapsedTimeSinceEpoch(default(DateTime?)).get_TotalMilliseconds()); this.m_whispers.Add(bnetWhisper); }
public static new BnetGameAccountId CreateFromEntityId(bgs.types.EntityId src) { BnetGameAccountId bnetGameAccountId = new BnetGameAccountId(); bnetGameAccountId.CopyFrom(src); return(bnetGameAccountId); }
public static new BnetGameAccountId CreateFromProtocol(bnet.protocol.EntityId src) { BnetGameAccountId bnetGameAccountId = new BnetGameAccountId(); bnetGameAccountId.SetLo(src.Low); bnetGameAccountId.SetHi(src.High); return(bnetGameAccountId); }
public static bool IsMember(PartyId partyId, BnetGameAccountId memberId) { if (partyId == null) { return(false); } PartyMember member = BnetParty.GetMember(partyId, memberId); return(member != null); }
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 PartyMember GetMember(PartyId partyId, BnetGameAccountId memberId) { foreach (PartyMember partyMember in BnetParty.GetMembers(partyId)) { if (partyMember.GameAccountId == memberId) { return(partyMember); } } return(null); }
public static void KickMember(PartyId partyId, BnetGameAccountId memberId) { if (!BnetParty.IsInParty(partyId)) { return; } EntityId partyId2 = partyId.ToEntityId(); EntityId memberId2 = BnetEntityId.CreateEntityId(memberId); BattleNet.KickPartyMember(partyId2, memberId2); }
public static void SetLeader(PartyId partyId, BnetGameAccountId memberId) { if (!BnetParty.IsInParty(partyId)) { return; } EntityId partyId2 = partyId.ToEntityId(); EntityId memberId2 = BnetEntityId.CreateEntityId(memberId); PartyType partyType = BnetParty.GetPartyType(partyId); uint leaderRoleId = PartyMember.GetLeaderRoleId(partyType); BattleNet.AssignPartyRole(partyId2, memberId2, leaderRoleId); }
public static PartyMember GetMyselfMember(PartyId partyId) { if (partyId == null) { return(null); } BnetGameAccountId bnetGameAccountId = BnetGameAccountId.CreateFromEntityId(BattleNet.GetMyGameAccountId()); if (bnetGameAccountId == null) { return(null); } return(BnetParty.GetMember(partyId, bnetGameAccountId)); }
public static void RequestInvite(PartyId partyId, BnetGameAccountId whomToAskForApproval, BnetGameAccountId whomToInvite, PartyType partyType) { if (BnetParty.IsLeader(partyId)) { PartyError error = default(PartyError); error.IsOperationCallback = true; error.DebugContext = "RequestInvite"; error.ErrorCode = BattleNetErrors.ERROR_INVALID_TARGET_ID; error.Feature = BnetFeature.Party; error.FeatureEvent = BnetFeatureEvent.Party_RequestPartyInvite_Callback; error.PartyId = partyId; error.szPartyType = EnumUtils.GetString <PartyType>(partyType); error.StringData = "leaders cannot RequestInvite - use SendInvite instead."; BnetParty.OnError(error); return; } EntityId partyId2 = partyId.ToEntityId(); EntityId whomToAskForApproval2 = BnetEntityId.CreateEntityId(whomToAskForApproval); EntityId whomToInvite2 = BnetEntityId.CreateEntityId(whomToInvite); string @string = EnumUtils.GetString <PartyType>(partyType); BattleNet.RequestPartyInvite(partyId2, whomToAskForApproval2, whomToInvite2, @string); }
public static PartyMember[] GetMembers(PartyId partyId) { if (partyId == null) { return(new PartyMember[0]); } PartyMember[] array; BattleNet.GetPartyMembers(partyId.ToEntityId(), out array); PartyMember[] array2 = new PartyMember[array.Length]; for (int i = 0; i < array2.Length; i++) { PartyMember partyMember = array[i]; array2[i] = new PartyMember { GameAccountId = BnetGameAccountId.CreateFromEntityId(partyMember.memberGameAccountId), RoleIds = new uint[] { partyMember.firstMemberRole } }; } return(array2); }
public static void Process() { PartyListenerEvent[] array; BattleNet.GetPartyListenerEvents(out array); BattleNet.ClearPartyListenerEvents(); int i = 0; while (i < array.Length) { PartyListenerEvent partyListenerEvent = array[i]; PartyId partyId = partyListenerEvent.PartyId; switch (partyListenerEvent.Type) { case PartyListenerEventType.ERROR_RAISED: case PartyListenerEventType.OPERATION_CALLBACK: { PartyError error = partyListenerEvent.ToPartyError(); if (error.ErrorCode != BattleNetErrors.ERROR_OK) { if (BnetParty.IsIgnorableError(error.FeatureEvent, error.ErrorCode.EnumVal)) { error.ErrorCode = BattleNetErrors.ERROR_OK; if (error.FeatureEvent == BnetFeatureEvent.Party_Leave_Callback) { if (!BnetParty.s_joinedParties.ContainsKey(partyId)) { BnetParty.s_joinedParties[partyId] = PartyType.SPECTATOR_PARTY; } goto IL_22D; } } if (error.IsOperationCallback && error.FeatureEvent == BnetFeatureEvent.Party_Create_Callback) { PartyType partyType = error.PartyType; if (BnetParty.s_pendingPartyCreates.ContainsKey(partyType)) { BnetParty.s_pendingPartyCreates.Remove(partyType); } } } if (error.ErrorCode != BattleNetErrors.ERROR_OK) { BnetParty.RaisePartyError(error); } break; } case PartyListenerEventType.JOINED_PARTY: { string stringData = partyListenerEvent.StringData; PartyType partyTypeFromString = BnetParty.GetPartyTypeFromString(stringData); BnetParty.s_joinedParties[partyId] = partyTypeFromString; if (BnetParty.s_pendingPartyCreates != null) { BnetParty.CreateSuccessCallback createSuccessCallback = null; if (BnetParty.s_pendingPartyCreates.ContainsKey(partyTypeFromString)) { createSuccessCallback = BnetParty.s_pendingPartyCreates[partyTypeFromString]; BnetParty.s_pendingPartyCreates.Remove(partyTypeFromString); } else if (stringData == "default" && BnetParty.s_pendingPartyCreates.Count == 0) { createSuccessCallback = BnetParty.s_pendingPartyCreates.First <KeyValuePair <PartyType, BnetParty.CreateSuccessCallback> >().Value; BnetParty.s_pendingPartyCreates.Clear(); } if (createSuccessCallback != null) { createSuccessCallback(partyTypeFromString, partyId); } } if (BnetParty.OnJoined != null) { BnetParty.OnJoined(OnlineEventType.ADDED, new PartyInfo(partyId, partyTypeFromString), null); } break; } case PartyListenerEventType.LEFT_PARTY: goto IL_22D; case PartyListenerEventType.PRIVACY_CHANGED: if (BnetParty.OnPrivacyLevelChanged != null) { BnetParty.OnPrivacyLevelChanged(BnetParty.GetJoinedParty(partyId), (PrivacyLevel)partyListenerEvent.UintData); } break; case PartyListenerEventType.MEMBER_JOINED: case PartyListenerEventType.MEMBER_LEFT: if (BnetParty.OnMemberEvent != null) { OnlineEventType evt = (partyListenerEvent.Type != PartyListenerEventType.MEMBER_JOINED) ? OnlineEventType.REMOVED : OnlineEventType.ADDED; LeaveReason? reason = null; if (partyListenerEvent.Type == PartyListenerEventType.MEMBER_LEFT) { reason = new LeaveReason?((LeaveReason)partyListenerEvent.UintData); } BnetParty.OnMemberEvent(evt, BnetParty.GetJoinedParty(partyId), partyListenerEvent.SubjectMemberId, false, reason); } break; case PartyListenerEventType.MEMBER_ROLE_CHANGED: if (BnetParty.OnMemberEvent != null) { BnetParty.OnMemberEvent(OnlineEventType.UPDATED, BnetParty.GetJoinedParty(partyId), partyListenerEvent.SubjectMemberId, true, null); } break; case PartyListenerEventType.RECEIVED_INVITE_ADDED: case PartyListenerEventType.RECEIVED_INVITE_REMOVED: if (BnetParty.OnReceivedInvite != null) { OnlineEventType evt2 = (partyListenerEvent.Type != PartyListenerEventType.RECEIVED_INVITE_ADDED) ? OnlineEventType.REMOVED : OnlineEventType.ADDED; PartyType type = PartyType.DEFAULT; if (partyListenerEvent.StringData != null) { EnumUtils.TryGetEnum <PartyType>(partyListenerEvent.StringData, out type); } PartyInfo party = new PartyInfo(partyId, type); InviteRemoveReason?reason2 = null; if (partyListenerEvent.Type == PartyListenerEventType.RECEIVED_INVITE_REMOVED) { reason2 = new InviteRemoveReason?((InviteRemoveReason)partyListenerEvent.UintData); } BnetParty.OnReceivedInvite(evt2, party, partyListenerEvent.UlongData, reason2); } break; case PartyListenerEventType.PARTY_INVITE_SENT: case PartyListenerEventType.PARTY_INVITE_REMOVED: if (BnetParty.OnSentInvite != null) { bool senderIsMyself = partyListenerEvent.SubjectMemberId == BnetGameAccountId.CreateFromEntityId(BattleNet.GetMyGameAccountId()); OnlineEventType evt3 = (partyListenerEvent.Type != PartyListenerEventType.PARTY_INVITE_SENT) ? OnlineEventType.REMOVED : OnlineEventType.ADDED; PartyType type2 = PartyType.DEFAULT; if (partyListenerEvent.StringData != null) { EnumUtils.TryGetEnum <PartyType>(partyListenerEvent.StringData, out type2); } PartyInfo party2 = new PartyInfo(partyId, type2); InviteRemoveReason?reason3 = null; if (partyListenerEvent.Type == PartyListenerEventType.PARTY_INVITE_REMOVED) { reason3 = new InviteRemoveReason?((InviteRemoveReason)partyListenerEvent.UintData); } BnetParty.OnSentInvite(evt3, party2, partyListenerEvent.UlongData, senderIsMyself, reason3); } break; case PartyListenerEventType.INVITE_REQUEST_ADDED: case PartyListenerEventType.INVITE_REQUEST_REMOVED: if (BnetParty.OnSentInvite != null) { OnlineEventType evt4 = (partyListenerEvent.Type != PartyListenerEventType.INVITE_REQUEST_ADDED) ? OnlineEventType.REMOVED : OnlineEventType.ADDED; PartyInfo joinedParty = BnetParty.GetJoinedParty(partyId); InviteRequestRemovedReason?reason4 = null; if (partyListenerEvent.Type == PartyListenerEventType.INVITE_REQUEST_REMOVED) { reason4 = new InviteRequestRemovedReason?((InviteRequestRemovedReason)partyListenerEvent.UintData); } InviteRequest inviteRequest = new InviteRequest(); inviteRequest.TargetId = partyListenerEvent.TargetMemberId; inviteRequest.TargetName = partyListenerEvent.StringData2; inviteRequest.RequesterId = partyListenerEvent.SubjectMemberId; inviteRequest.RequesterName = partyListenerEvent.StringData; BnetParty.OnReceivedInviteRequest(evt4, joinedParty, inviteRequest, reason4); } break; case PartyListenerEventType.CHAT_MESSAGE_RECEIVED: if (BnetParty.OnChatMessage != null) { BnetParty.OnChatMessage(BnetParty.GetJoinedParty(partyId), partyListenerEvent.SubjectMemberId, partyListenerEvent.StringData); } break; case PartyListenerEventType.PARTY_ATTRIBUTE_CHANGED: { PartyInfo joinedParty2 = BnetParty.GetJoinedParty(partyId); string stringData2 = partyListenerEvent.StringData; if (stringData2 == "WTCG.Party.Type") { string partyAttributeString = BnetParty.GetPartyAttributeString(partyId, "WTCG.Party.Type"); PartyType partyTypeFromString2 = BnetParty.GetPartyTypeFromString(partyAttributeString); if (partyTypeFromString2 != PartyType.DEFAULT) { BnetParty.s_joinedParties[partyId] = partyTypeFromString2; } } Variant variant = null; switch (partyListenerEvent.UintData) { case 1u: variant = new Variant(); variant.IntValue = (long)partyListenerEvent.UlongData; break; case 2u: variant = new Variant(); variant.StringValue = partyListenerEvent.StringData2; break; case 3u: variant = new Variant(); variant.BlobValue = partyListenerEvent.BlobData; break; } IL_611: if (BnetParty.OnPartyAttributeChanged != null) { BnetParty.OnPartyAttributeChanged(joinedParty2, stringData2, variant); } List <BnetParty.PartyAttributeChangedHandler> list; if (BnetParty.s_attributeChangedSubscribers != null && BnetParty.s_attributeChangedSubscribers.TryGetValue(stringData2, out list)) { BnetParty.PartyAttributeChangedHandler[] array2 = list.ToArray(); foreach (BnetParty.PartyAttributeChangedHandler partyAttributeChangedHandler in array2) { partyAttributeChangedHandler(joinedParty2, stringData2, variant); } } break; goto IL_611; } } IL_68C: i++; continue; IL_22D: if (BnetParty.s_joinedParties.ContainsKey(partyId)) { PartyType type3 = BnetParty.s_joinedParties[partyId]; BnetParty.s_joinedParties.Remove(partyId); if (BnetParty.OnJoined != null) { BnetParty.OnJoined(OnlineEventType.REMOVED, new PartyInfo(partyId, type3), new LeaveReason?((LeaveReason)partyListenerEvent.UintData)); } } goto IL_68C; } }
public void SetReceiverId(BnetGameAccountId id) { this.m_receiverId = id; }
public static void SendWhisper(BnetGameAccountId gameAccount, string message) { BattleNet.s_impl.SendWhisper(gameAccount, message); }
public static void AcceptInviteRequest(PartyId partyId, BnetGameAccountId requestedTargetId) { BnetParty.SendInvite(partyId, requestedTargetId); }
public void SetSpeakerId(BnetGameAccountId id) { this.m_speakerId = id; }
public static PartyInvite GetReceivedInviteFrom(BnetGameAccountId inviterId, PartyType partyType) { PartyInvite[] receivedInvites = BnetParty.GetReceivedInvites(); return(receivedInvites.FirstOrDefault((PartyInvite i) => i.InviterId == inviterId && i.PartyType == partyType)); }