public override async Task <SendMessageResponse> SendMessage(SendMessageRequest request, ServerCallContext context) { DbUserModel dbUserModel = context.UserState["user"] as DbUserModel; if (dbUserModel == null) { return new SendMessageResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; Room room = await Room.GetRoomFromGuid(request.RoomId); if (room == null) { return new SendMessageResponse() { Status = ResponseFactory.createResponse(ResponseType.ROOM_DOES_NOT_EXIST) } } ; GroupChat groupChat = await room.GetGroupChatById(request.GroupId); if (groupChat == null) { return new SendMessageResponse() { Status = ResponseFactory.createResponse(ResponseType.CHAT_GROUP_DOES_NOT_EXIST) } } ; if (!groupChat.IsPlayerInGroup(dbUserModel)) { return new SendMessageResponse() { Status = ResponseFactory.createResponse(ResponseType.PERMISSION_DENIED) } } ; return(new SendMessageResponse() { Status = await groupChat.SendChatMessage(dbUserModel, request.Message) }); }