/// <summary> /// Написать сообщение /// </summary> /// <param name="model"></param> /// <returns></returns> public Task <BaseApiResponse <ChatMessageModel> > SendMessage(SendMessageToChat model) { var ticks = DateTime.UtcNow.Ticks; var id = Guid.NewGuid().ToString(); CreateHandled(new EccChatMessage { Id = id, ChatId = model.ChatId, TagString = model.TagString, SentOnUtcTicks = ticks, LastUpdateOnUtcTicks = ticks, Message = model.Message, SenderUserId = UserId }); var resModel = new ChatMessageModel { Id = id, Message = model.Message, LastUpdateUtcTicks = ticks, SenderUserId = UserId, SentOnUtcTicks = ticks, TagString = model.TagString }; return(TrySaveChangesAndReturnResultAsync("Сообщение отправлено", resModel)); }
private void Update() { if (_allowEnter && _inputField.text.Length > 0 && Input.GetKey(KeyCode.Return)) { SendMessageToChat?.Invoke(_inputField.text); _allowEnter = false; _inputField.text = ""; } else { _allowEnter = _inputField.isFocused; } }
public async Task SendMessage(SendMessageToChat model) { var res = await GetTransactionHandler().ExecuteAndCloseTransaction(amb => { return(new ApplicationChatService(amb).SendMessage(model)); }); if (res.IsSucceeded) { var connections = GetUserConnectionIdsInChat(model.ChatId); await Clients.Users(connections).SendAsync("onNewMessage", new ChatIdWithMessage { ChatId = model.ChatId, Message = res.ResponseObject, }); } }
public Task <BaseApiResponse <ChatMessageModel> > SendMessage(SendMessageToChat model) { var resModel = new ChatMessageModel { Message = model.Message, SenderUserId = UserId, SentOnUtcTicks = DateTime.UtcNow.Ticks }; CreateHandled(new ApplicationChatMessage { Id = Guid.NewGuid().ToString(), ChatId = model.ChatId, SentOnUtcTicks = resModel.SentOnUtcTicks, Message = resModel.Message, SenderUserId = UserId }); return(TrySaveChangesAndReturnResultAsync("Сообщение отправлено", resModel)); }