示例#1
0
        public async Task <ValuePair <TokenVm, UserVm> > CheckTokenAsync(long userId, TokenVm token, long nodeId)
        {
            var nodeConnection = connectionsService.GetNodeConnection(nodeId);

            if (nodeConnection != null)
            {
                CheckTokenNodeRequest request = new CheckTokenNodeRequest(userId, token);
                SendRequest(nodeConnection, request);
                NodeResponse nodeResponse = await GetResponseAsync(request).ConfigureAwait(false);

                switch (nodeResponse.ResponseType)
                {
                case NodeResponseType.UserTokens:
                {
                    UserTokensNodeResponse tokensResponse = (UserTokensNodeResponse)nodeResponse;
                    return(new ValuePair <TokenVm, UserVm>(tokensResponse.Token, tokensResponse.User));
                }

                default:
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
 public CheckTokenRequestHandler(CommunicationObject request, NodeConnection current, ITokensService tokensService, ILoadUsersService loadUsersService)
 {
     this.request          = (CheckTokenNodeRequest)request;
     this.current          = current;
     this.loadUsersService = loadUsersService;
     this.tokensService    = tokensService;
 }