public async Task <IHttpActionResult> SendMessage(int chatId, [FromBody] ChatSendMessageRequest request)
        {
            var result = await clientConnector.SendChatMessage(chatId, request.Message);

            if (result)
            {
                return(this.Ok());
            }
            return(this.InternalServerError());
        }
Example #2
0
 public JsonResult Send(ChatSendMessageRequest msg)
 {
     var chatServer = ServiceLocator.GetInstance<IChatServer>();
     IChatRoom room = null;
     if (msg.RoomId.HasValue())
         room = chatServer.GetRoom(msg.RoomId);
     if (room == null)
         room = chatServer.GetRoomFor(msg.From, msg.To, true);
     room.PostMessage(msg.SenderKey, msg.From, msg.Message);
     return Json(new ChatSendMessageResult() { RoomId = room.RoomId }, JsonRequestBehavior.DenyGet);
 }
Example #3
0
        public JsonResult Send(ChatSendMessageRequest msg)
        {
            var       chatServer = ServiceLocator.GetInstance <IChatServer>();
            IChatRoom room       = null;

            if (msg.RoomId.HasValue())
            {
                room = chatServer.GetRoom(msg.RoomId);
            }
            if (room == null)
            {
                room = chatServer.GetRoomFor(msg.From, msg.To, true);
            }
            room.PostMessage(msg.SenderKey, msg.From, msg.Message);
            return(Json(new ChatSendMessageResult()
            {
                RoomId = room.RoomId
            }, JsonRequestBehavior.DenyGet));
        }