示例#1
0
        public override async Task <GetChatReply> TakeChats(GetChats request, ServerCallContext context)
        {
            if (request?.UserId is null)
            {
                _logger.LogError("Request is null");
                return(new GetChatReply
                {
                    Response = Response.Error
                });
            }

            _logger.LogInformation("Chats search started");

            var chats = await _chatRepository.GetChatsAsync(request.UserId);

            if (chats is null)
            {
                _logger.LogError("No chat found");
                return(new GetChatReply
                {
                    Response = Response.Error
                });
            }

            _logger.LogInformation("Chat(s) found await reply");

            return(new GetChatReply
            {
                Response = Response.Ok,
                Chats =
                {
                    _mapper.Map <RepeatedField <Chat> >(chats)
                }
            });
        }
示例#2
0
        public ViewModel(string username)
        {
            // Set visible username
            CUsername = username;

            // Initialize empty chats
            UserChats = new ObservableCollection <Chat>();

            // Commands initialization
            Logout         = new Logout(this);
            MessageEntered = new MessageEntered(this);
            SearchUsername = new SearchUsername(this);

            ChatMessages = new ObservableCollection <string>();

            // Create locks for accessing across threads
            UserChatsLock = new object();
            BindingOperations.EnableCollectionSynchronization(UserChats, UserChatsLock);

            ChatMessagesLock = new object();
            BindingOperations.EnableCollectionSynchronization(ChatMessages, ChatMessagesLock);

            // Get existing chats from server
            IRequest request = new GetChats();

            Session.SendRequest(request);
        }
 public List <IChatModel> Any(GetChats request)
 {
     return(workflow.Search(request));
 }
示例#4
0
 public RoomViewComponent(GetChats getChats)
 {
     _getChats = getChats;
 }