Beispiel #1
0
        public async Task AcceptUserRequest(string mentorId, string userId, string userConnectionId)
        {
            var room = _communicationService.GenerateConnectionId();

            try
            {
                CurrentRoom = room;
                await Groups.RemoveFromGroupAsync(Context.ConnectionId, Mentor);

                await Groups.AddToGroupAsync(userConnectionId, room);

                await Clients.Client(userConnectionId).SendAsync("Room", room);

                await _messageService.AndUsersToRoom(mentorId, userId, room);

                await Groups.AddToGroupAsync(Context.ConnectionId, room);

                await Clients.Caller.SendAsync("Room", room);

                await Clients.Group(room).SendAsync("ReceiveMessage", "HopeLine", "Welcome to HopeLine Chatroom");
            }
            catch (System.Exception ex)
            {
                _logger.LogCritical("Unable to Accept Request.", room, userId, ex);
            }

            //Creating new Conversation
            var result = _communicationService.AddConversation(new ConversationModel
            {
                PIN                = room,
                UserId             = userId,
                MentorId           = mentorId,
                DateOfConversation = DateTime.Now
            });

            if (!result)
            {
                _logger.LogWarning("Adding Conversation Failed", room, userId);
            }
            else
            {
                _logger.LogInformation("Adding Conversation", room, userId);
            }
        }