public void SendWhisper(BnetGameAccountId gameAccount, string message) { if (!string.IsNullOrEmpty(message)) { bnet.protocol.notification.Notification notification = new bnet.protocol.notification.Notification(); notification.SetType("WHISPER"); EntityId val = new EntityId(); val.SetLow(gameAccount.GetLo()); val.SetHigh(gameAccount.GetHi()); notification.SetTargetId(val); bnet.protocol.attribute.Attribute attribute = new bnet.protocol.attribute.Attribute(); attribute.SetName("whisper"); bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant(); variant.SetStringValue(message); attribute.SetValue(variant); notification.AddAttribute(attribute); base.m_rpcConnection.QueueRequest(base.m_battleNet.NotificationService.Id, 1, notification, new RPCContextDelegate(this.WhisperSentCallback), 0); BnetGameAccountId id = BnetGameAccountId.CreateFromDll(BattleNet.GetMyGameAccountId()); BnetWhisper item = new BnetWhisper(); item.SetSpeakerId(id); item.SetReceiverId(gameAccount); item.SetMessage(message); TimeSpan elapsedTimeSinceEpoch = TimeUtils.GetElapsedTimeSinceEpoch(null); item.SetTimestampMilliseconds(elapsedTimeSinceEpoch.TotalMilliseconds); this.m_whispers.Add(item); } }
public void OnWhisper(bnet.protocol.notification.Notification notification) { if (notification.HasSenderId && (notification.AttributeCount > 0)) { BnetWhisper item = new BnetWhisper(); item.SetSpeakerId(BnetGameAccountId.CreateFromProtocol(notification.SenderId)); item.SetReceiverId(BnetGameAccountId.CreateFromProtocol(notification.TargetId)); for (int i = 0; i < notification.AttributeCount; i++) { bnet.protocol.attribute.Attribute attribute = notification.Attribute[i]; if (attribute.Name == "whisper") { item.SetMessage(attribute.Value.StringValue); } } if (!string.IsNullOrEmpty(item.GetMessage())) { TimeSpan elapsedTimeSinceEpoch = TimeUtils.GetElapsedTimeSinceEpoch(null); item.SetTimestampMilliseconds(elapsedTimeSinceEpoch.TotalMilliseconds); this.m_whispers.Add(item); } } }