Beispiel #1
0
        public async Task <ActionResult> createRoom(int recipientId)
        {
            int          code     = 200;
            BaseResponse response = null;

            try
            {
                int   userId     = _authService.GetCurrentUserId();
                int[] usersArray = new int[] { userId, recipientId };
                Array.Sort(usersArray);
                string chatRoomId = $"{usersArray[0]}_{usersArray[1]}";

                HttpResponseMessage responseContent = await _service.createRoom(chatRoomId);

                var responseStream = await responseContent.Content.ReadAsStreamAsync();

                var jsonresponse = await JsonSerializer.DeserializeAsync <Object>(responseStream);

                response = new ItemResponse <Object> {
                    Item = jsonresponse
                };
            }
            catch (Exception ex)
            {
                code = 500;
                Logger.LogError(ex.ToString());
                response = new ErrorResponse(ex.Message);
            }
            return(StatusCode(code, response));
        }
Beispiel #2
0
        public async Task StartVideoChat()
        {
            try
            {
                int    userId     = _authService.GetCurrentUserId();
                string chatRoomId = await _chatHubService.GetCurrentUserRoom(userId);

                HttpResponseMessage response = await _videoChatService.createRoom(chatRoomId);

                var responseStream = await response.Content.ReadAsStreamAsync();

                var jsonresponse = await JsonSerializer.DeserializeAsync <Object>(responseStream);

                var finalResponse = new ItemResponse <Object> {
                    Item = jsonresponse
                };
                await Clients.Group(chatRoomId).SendAsync("AddVideoMessage", finalResponse);
            }
            catch (Exception ex)
            {
                await Clients.Caller.SendAsync("AddVideoMessage", null, ex);
            }
        }