/// <summary> /// 接收来自该用户的消息 /// </summary> /// <param name="msg"></param> public void ReceiveMsg(WXMsg msg) { _recevedMsg.Add(msg.Time, msg); if (MsgReceved != null) { MsgReceved(msg); } }
/// <summary> /// 向该用户发送消息 /// </summary> /// <param name="msg"></param> /// <param name="showOnly"></param> public void SendMsg(WXMsg msg, bool showOnly) { if (!showOnly) { WXService wxs = new WXService(); wxs.SendMsg(msg.Msg, msg.From, msg.To, msg.Type); } _sentMsg.Add(msg.Time, msg); if (MsgSent != null) { MsgSent(msg); } }
/// <summary> /// 获取最近的一条信息 /// </summary> /// <returns></returns> public WXMsg GetLatestMsg() { WXMsg msg = null; if (_sentMsg.Count > 0 && _recevedMsg.Count > 0) { msg = _sentMsg.Last().Value.Time > _recevedMsg.Last().Value.Time ? _sentMsg.Last().Value : _recevedMsg.Last().Value; } else if (_sentMsg.Count > 0) { msg = _sentMsg.Last().Value; } else if (_recevedMsg.Count > 0) { msg = _recevedMsg.Last().Value; } return(msg); }