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 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); }