/// <summary> /// 向目标用户发送文本消息, 失败时不抛出异常 /// </summary> public async Task PutTextAsync(Profile profile, string text) { if (profile == null) { throw new ArgumentNullException(nameof(profile)); } var message = new NotifyTextMessage(); message.SetObject(text); var packetData = new { messageId = message.MessageId, text, }; await this.dispatcher.InvokeAsync(() => this.InsertMessageAsync((NotifyClientProfile)profile, message)); await this.network.PutAsync((NotifyClientProfile)profile, message, "link.message.text", packetData); }
NotifyPropertyMessage Convert(MessageEntry item) { if (item.Path == NotifyTextMessage.MessagePath) { var message = new NotifyTextMessage(item.MessageId, item.DateTime, AsMessageReference(item.Reference)); message.SetObject(item.Object); message.SetStatus(MessageStatus.Success); return(message); } else if (item.Path == NotifyImageMessage.MessagePath) { var message = new NotifyImageMessage(item.MessageId, item.DateTime, AsMessageReference(item.Reference)); var imageHash = item.Object; message.ImageHash = imageHash; message.SetStatus(MessageStatus.Success); if (this.cache.TryGetCache(imageHash, out var info)) { message.SetObject(info.FullName); } return(message); } return(default);