Ejemplo n.º 1
0
 /// <summary>
 /// 触发消息发送事件
 /// </summary>
 /// <param name="msg"></param>
 private void OnMsgSent(WeChatMsg msg)
 {
     if (MsgSent != null)
     {
         MsgSent(msg);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 触发消息接收事件
 /// </summary>
 /// <param name="msg"></param>
 private void OnMsgRecved(WeChatMsg msg)
 {
     if (MsgRecved != null)
     {
         MsgRecved(msg);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 向该用户发送消息
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="showOnly"></param>
 public void SendMsg(WeChatMsg msg, bool showOnly)
 {
     if (!showOnly)
     {
         WeChatService wcs = new WeChatService();
         wcs.SendMsg(msg.Msg, msg.From, msg.To, msg.Type);
     }
     _sentMsg.Add(Guid.NewGuid(), msg);
     OnMsgSent(msg);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取最近的一条消息
        /// </summary>
        /// <returns></returns>
        public WeChatMsg GetLatestMsg()
        {
            WeChatMsg 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;
            }

            return(msg);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 接收来自该用户的消息
 /// </summary>
 /// <param name="msg"></param>
 public void ReceivedMsg(WeChatMsg msg)
 {
     _recvedMsg.Add(Guid.NewGuid(), msg);
     OnMsgRecved(msg);;
 }