예제 #1
0
        public async Task <IActionResult> Send([FromBody] MessageModel model)
        {
            var sentMessage = await _messageService.Send(Mapper.Map <Message>(model));

            model.Id = sentMessage.Id;
            await _chat.SendMessageToAllAsync(JsonCamelSerializer.Serialize(model));

            return(Ok());
        }
예제 #2
0
        public async Task <IActionResult> NotifyAllConnectedSockets([FromBody] RequestMessage req)
        {
            try
            {
                if (!req.IsValid())
                {
                    return(BadRequest("Invalid request body"));
                }

                await _messageHandler.SendMessageToAllAsync(req.Message);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }