/// <summary> /// 收到消息 /// </summary> /// <param name="msg">Message</param> public void ProcessNewMessage(Messageobject msg) { //处理撤回消息 switch (msg.type) { case kWCMessageType.RoomMemberNameChange: UpdateGroupMemberRemark(new MessageListItem { Jid = msg.fromUserId, ShowTitle = msg.content, Avator = Applicate.LocalConfigData.GetDisplayAvatorPath(msg.fromUserId) }); break; case kWCMessageType.Withdraw: var withdraw = ChatMessageList.FirstOrDefault(m => m.messageId == msg.content); if (withdraw != null) { ChatMessageList.Remove(withdraw); //移除对应消息 } break; case kWCMessageType.PokeMessage: //戳一戳 break; case kWCMessageType.RoomFileDelete: //文件删除 break; default: break; } }
/// <summary> /// 删除消息 /// </summary> /// <param name="msg">需要删除的消息</param> private void RemoveMessage(Messageobject msg) { var msgItem = ChatMessageList.FirstOrDefault(m => m.messageId == msg.messageId);//获取 if (msgItem != null) { ChatMessageList.Remove(msgItem);//删除 } }
/// <summary> /// 根据MessageId设置消息的 /// </summary> /// <param name="msgId"></param> private void UpdateMessageSended(string msgId) { var existsItem = ChatMessageList.FirstOrDefault(m => m.messageId == msgId); if (existsItem != null) { existsItem.messageState = 1; //设为送达 existsItem.StateIcon = PackIconKind.Check; //设为送达 existsItem.MsgStateText = "送达"; existsItem.ReadToolTip = "送达"; } }
public void MsgReceipt(Messageobject msg) { var existsItem = ChatMessageList.FirstOrDefault(m => m.messageId == msg.messageId);//获取对应消息 if (existsItem != null) { existsItem.messageState = 1; //设为送达 existsItem.StateIcon = PackIconKind.Check; //设为送达 existsItem.MsgStateText = "送达"; existsItem.ReadToolTip = "送达"; } }
public void SendTimeout(Messageobject msg) { var target = ChatMessageList.FirstOrDefault(m => m.messageId == msg.messageId); if (target != null) { target.messageState = -1; //target.StateIcon = PackIconKind.AlertCircle; target.UpdateMessageState(); //target = target; } }
/// <summary> /// 撤回消息 /// </summary> /// <param name="msg">需要撤回的消息</param> private void WithDrawMessage(Messageobject msg) { if (ChatMessageList.Count(c => c.messageId == msg.messageId) > 0) { var cmsg = ChatMessageList.FirstOrDefault(c => c.messageId == msg.messageId); cmsg.content = msg.content; //内容 cmsg.type = msg.type; //更新为撤回消息 #region 移除并添加 int index = ChatMessageList.IndexOf(cmsg); ChatMessageList.Remove(cmsg); ChatMessageList.Insert(index, cmsg); #endregion } }