예제 #1
0
 /// <summary>
 /// 向该用户发送消息
 /// </summary>
 /// <param name="msg"></param>
 public void SendMsg(WXMsg msg, bool showOnly)
 {
     try
     {
         if (!showOnly)
         {
             WXService wxs = new WXService();
             wxs.SendMsg(msg.Msg, msg.From, msg.To, msg.Type, msg.Uin, msg.Sid);
         }
         _sentMsg.Add(msg.Time, msg);
         MsgSent.Invoke(msg);
     }
     catch
     {
         return;
     }
 }
예제 #2
0
 /// <summary>
 /// 接收来自该用户的消息
 /// </summary>
 /// <param name="msg"></param>
 public void ReceiveMsg(WXMsg msg)
 {
     _recvedMsg.Add(msg.Time, msg);
     if (MsgRecved != null)
     {
         MsgRecved(msg);
         return;
     }
     //try
     //{
     //    _recvedMsg.Add(msg.Time, msg);
     //}
     //catch
     //{
     //    // MsgRecved(null);
     //    return;
     //}
 }
예제 #3
0
        /// <summary>
        /// 获取最近的一条消息
        /// </summary>
        /// <returns></returns>
        public WXMsg GetLatestMsg()
        {
            WXMsg msg = null;

            if (_sentMsg.Count > 0 && _recvedMsg.Count > 0)
            {
                msg = _sentMsg.Last().Value.Time > _recvedMsg.Last().Value.Time ? _sentMsg.Last().Value : _recvedMsg.Last().Value;
            }
            else if (_sentMsg.Count > 0)
            {
                msg = _sentMsg.Last().Value;
            }
            else if (_recvedMsg.Count > 0)
            {
                msg = _recvedMsg.Last().Value;
            }
            else
            {
                msg = null;
            }
            return(msg);
        }