コード例 #1
0
            public static (IQueueItem, Task <TResponseType?>) Create(
                bool mutatesSolutionState,
                bool requiresLSPSolution,
                ClientCapabilities clientCapabilities,
                string methodName,
                TextDocumentIdentifier?textDocument,
                TRequestType request,
                IRequestHandler <TRequestType, TResponseType> handler,
                Guid activityId,
                ILspLogger logger,
                RequestTelemetryLogger telemetryLogger,
                CancellationToken cancellationToken)
            {
                var queueItem = new QueueItem <TRequestType, TResponseType>(
                    mutatesSolutionState,
                    requiresLSPSolution,
                    clientCapabilities,
                    methodName,
                    textDocument,
                    request,
                    handler,
                    activityId,
                    logger,
                    telemetryLogger,
                    cancellationToken);

                return(queueItem, queueItem._completionSource.Task);
            }
コード例 #2
0
            public QueueItem(
                bool mutatesSolutionState,
                bool requiresLSPSolution,
                ClientCapabilities clientCapabilities,
                string methodName,
                TextDocumentIdentifier?textDocument,
                TRequestType request,
                IRequestHandler <TRequestType, TResponseType> handler,
                Guid activityId,
                ILspLogger logger,
                RequestTelemetryLogger telemetryLogger,
                CancellationToken cancellationToken)
            {
                // Set the tcs state to cancelled if the token gets cancelled outside of our callback (for example the server shutting down).
                cancellationToken.Register(() => _completionSource.TrySetCanceled(cancellationToken));

                Metrics = new RequestMetrics(methodName, telemetryLogger);

                _handler = handler;
                _logger  = logger;
                _request = request;

                ActivityId           = activityId;
                MutatesSolutionState = mutatesSolutionState;
                RequiresLSPSolution  = requiresLSPSolution;
                ClientCapabilities   = clientCapabilities;
                MethodName           = methodName;
                TextDocument         = textDocument;
            }
コード例 #3
0
        internal static TRequestType CreateRequestType <TRequestType>() where TRequestType : BaseRequest, new()
        {
            var item = new TRequestType
            {
                Username = Username,
                Password = Password
            };

            return(item);
        }
コード例 #4
0
 private void AddRequest(TRequestType request, Exchange exchange)
 {
     lock (_Requests)
     {
         _Requests.Enqueue(new ClientRequest()
         {
             RequestType = request, Exchange = exchange
         });
     }
     _TriggerProcessRequests.Set();
 }
コード例 #5
0
        void IMessageDeliverer.DeliverRequest(Exchange exchange)
        {
            Request      request     = exchange.Request;
            TRequestType requestType = TRequestType.NotSet;

            if (request.Method == Method.POST)
            {
                if (request.URI.AbsolutePath == "/bs")
                {
                    requestType = TRequestType.RequestBootstrap;
                }
            }
            if (requestType == TRequestType.NotSet)
            {
                exchange.SendReject();
            }
            else
            {
                AddRequest(requestType, exchange);
            }
        }
コード例 #6
0
ファイル: Server.cs プロジェクト: tuga1975/DeviceServer
        void IMessageDeliverer.DeliverRequest(Exchange exchange)
        {
            Request      request     = exchange.Request;
            TRequestType requestType = TRequestType.NotSet;

            if (request.Method == Method.POST)
            {
                if (request.URI.AbsolutePath == "/rd")
                {
                    if ((request.ContentType == (int)MediaType.ApplicationLinkFormat) || (request.ContentType == -1))
                    //if (request.ContentType == (int)MediaType.ApplicationLinkFormat)
                    {
                        requestType = TRequestType.Register;
                    }
                }
            }

            if (request.URI.AbsolutePath.StartsWith("/rd/"))
            {
                if ((request.Method == Method.POST) || (request.Method == Method.PUT))
                {
                    requestType = TRequestType.Update;
                }
                else if (request.Method == Method.DELETE)
                {
                    requestType = TRequestType.Deregister;
                }
            }
            if (requestType == TRequestType.NotSet)
            {
                exchange.SendReject();
            }
            else
            {
                AddRequest(requestType, exchange);
            }
        }
コード例 #7
0
ファイル: Server.cs プロジェクト: CreatorDev/DeviceServer
 private void AddRequest(TRequestType request, Exchange exchange)
 {
     lock (_Requests)
     {
         _Requests.Enqueue(new ClientRequest() { RequestType = request, Exchange = exchange });
     }
     _TriggerProcessRequests.Set();
 }
コード例 #8
0
 public RequestArg(TRequestType _type)
 {
     eType = _type;
 }