Example #1
0
        public RequestHandler(ServerInfo localServerInfo, SocketSettings settings)
        {
            _requestId       = 1;
            _localServerInfo = localServerInfo;
            _settings        = settings;

            _pendingRequests    = new List <Request>();
            _inProgressRequests = new List <Request>();
            _processedRequests  = new List <Request>();
            _sentRequests       = new List <Request>();
            _failedRequests     = new List <Request>();

            _requestSender = new RequestSender(localServerInfo, settings);
            _requestSender.EventOccurred           += HandleServerEvent;
            _requestSender.SuccessfullySentRequest += HandleSentRequest;

            CreateDecodeRequestFunctionsDictionary();
            CreateProcessRequestFunctionsDictionary();
        }
Example #2
0
        public async Task <Result> AcceptInboundFileTransferAsync(Request outboundRequest)
        {
            _transferRequestSender = new RequestSender(_localServerInfo, _settings);
            _transferRequestSender.EventOccurred           += HandleServerEvent;
            _transferRequestSender.SuccessfullySentRequest += HandleSentRequest;

            var sendRequest = await _transferRequestSender.SendAsync(outboundRequest);

            if (sendRequest.Success)
            {
                return(Result.Ok());
            }

            outboundRequest.Status = RequestStatus.Error;
            HandleFailedRequest(outboundRequest);
            ReportError(sendRequest.Error);

            return(Result.Fail(sendRequest.Error));
        }