Example #1
0
 private void OnWhisper(BnetWhisper whisper, object userData)
 {
     if ((this.m_receiver != null) && whisper.IsSpeaker(this.m_receiver))
     {
         this.UpdateReceiver();
     }
 }
 private void FireWhisperEvent(BnetWhisper whisper)
 {
     foreach (WhisperListener listener in this.m_whisperListeners.ToArray())
     {
         listener.Fire(whisper);
     }
 }
 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);
     }
 }
    private void AddWhisperMessage(BnetWhisper whisper)
    {
        string message = ChatUtils.GetMessage(whisper);
        MobileChatLogMessageFrame prefab = !whisper.IsSpeaker(this.receiver) ? this.prefabs.myMessage : this.prefabs.theirMessage;
        MobileChatLogMessageFrame item   = this.CreateMessage(prefab, message);

        this.messageFrames.Add(item);
    }
 private void OnWhisper(BnetWhisper whisper, object userData)
 {
     if ((this.receiver != null) && whisper.IsSpeakerOrReceiver(this.receiver))
     {
         this.AddWhisperMessage(whisper);
         this.messageFrames.ScrollValue = 1f;
     }
 }
 public void SetWhisper(BnetWhisper whisper)
 {
     if (this.m_whisper != whisper)
     {
         this.m_whisper = whisper;
         this.UpdateWhisper();
     }
 }
 private bool CanProcessPendingWhispers()
 {
     if (this.m_firstPendingWhisperIndex >= 0)
     {
         for (int i = this.m_firstPendingWhisperIndex; i < this.m_whispers.Count; i++)
         {
             BnetWhisper whisper = this.m_whispers[i];
             if (!whisper.IsDisplayable())
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #8
0
    private BnetWhisper FindLastWhisperFromReceiver()
    {
        List <BnetWhisper> whispersWithPlayer = BnetWhisperMgr.Get().GetWhispersWithPlayer(this.m_receiver);

        if (whispersWithPlayer != null)
        {
            for (int i = whispersWithPlayer.Count - 1; i >= 0; i--)
            {
                BnetWhisper whisper = whispersWithPlayer[i];
                if (whisper.IsSpeaker(this.m_receiver))
                {
                    return(whisper);
                }
            }
        }
        return(null);
    }
Example #9
0
 private void UpdateLastMessage()
 {
     if (this.m_chatLogFrame != null)
     {
         this.HideLastMessage();
     }
     else
     {
         BnetWhisper whisper = this.FindLastWhisperFromReceiver();
         if (whisper == null)
         {
             this.HideLastMessage();
         }
         else
         {
             this.m_LastMessageText.gameObject.SetActive(true);
             this.m_LastMessageText.Text = ChatUtils.GetMessage(whisper);
             TransformUtil.SetPoint((Component)this.m_LastMessageText, Anchor.BOTTOM_LEFT, (Component)this.m_Bones.m_LastMessage, Anchor.TOP_LEFT);
             this.m_ReceiverNameText.gameObject.SetActive(true);
             if (this.m_receiver.IsOnline())
             {
                 this.m_ReceiverNameText.TextColor = GameColors.PLAYER_NAME_ONLINE;
             }
             else
             {
                 this.m_ReceiverNameText.TextColor = GameColors.PLAYER_NAME_OFFLINE;
             }
             this.m_ReceiverNameText.Text = FriendUtils.GetUniqueName(this.m_receiver);
             TransformUtil.SetPoint((Component)this.m_ReceiverNameText, Anchor.BOTTOM_LEFT, (Component)this.m_LastMessageText, Anchor.TOP_LEFT);
             this.m_LastMessageShadow.SetActive(true);
             Bounds textWorldSpaceBounds = this.m_LastMessageText.GetTextWorldSpaceBounds();
             Bounds bounds2 = this.m_ReceiverNameText.GetTextWorldSpaceBounds();
             float  num     = Mathf.Max(textWorldSpaceBounds.max.y, bounds2.max.y);
             float  num2    = Mathf.Min(textWorldSpaceBounds.min.y, bounds2.min.y);
             float  num3    = num - num2;
             float  z       = (num3 * this.m_initialLastMessageShadowScaleZ) / this.m_initialLastMessageTextHeight;
             TransformUtil.SetLocalScaleZ(this.m_LastMessageShadow, z);
         }
     }
 }
 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);
         }
     }
 }
 public static string GetMessage(BnetWhisper whisper)
 {
     return(GetMessage(whisper.GetMessage()));
 }
 public void SetLastSeenWhisper(BnetWhisper whisper)
 {
     this.m_lastSeenWhisper = whisper;
 }