BuildAbort() 공개 정적인 메소드

public static BuildAbort ( IConnection connection, string transport, string connectionData ) : string
connection IConnection
transport string
connectionData string
리턴 string
예제 #1
0
 public void BuildAbortRetunsValidUrlWithConnectionDataAndCustomQueryString(string qs, string expected)
 {
     Assert.Equal(
         "http://fakeurl/abort?clientProtocol=1.42&transport=webPolling&connectionData=CustomConnectionData&connectionToken=My%20Conn%20Token" +
         expected,
         UrlBuilder.BuildAbort(CreateConnection(qs), "webPolling", "CustomConnectionData"));
 }
        public virtual void Abort(IConnection connection, TimeSpan timeout, string connectionData)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            // Save the connection.ConnectionToken since race issue that connection.ConnectionToken can be set to null in different thread
            var connectionToken = connection.ConnectionToken;

            if (connectionToken == null)
            {
                connection.Trace(TraceLevels.Messages, "Connection already disconnected, skipping abort.");
                return;
            }

            // Abort should never complete before any of its previous calls
            lock (_abortLock)
            {
                if (_disposed)
                {
                    return;
                }

                // Ensure that an abort request is only made once
                if (!_startedAbort)
                {
                    _startedAbort = true;

                    var url = UrlBuilder.BuildAbort(connection, _transportName, connectionData);

                    _httpClient.Post(url, connection.PrepareRequest, isLongRunning: false)
                    .Catch((ex, state) =>
                    {
                        // If there's an error making an http request set the reset event
                        ((TransportAbortHandler)state).CompleteAbort();
                    },
                           this,
                           connection);

                    if (!_abortResetEvent.WaitOne(timeout))
                    {
                        connection.Trace(TraceLevels.Events, "Abort never fired");
                    }
                }
            }
        }
예제 #3
0
            public void BuildAbortChecksInputParameters()
            {
                Assert.Equal("connection",
                             Assert.Throws <ArgumentNullException>(
                                 () => UrlBuilder.BuildAbort(null, "transport", string.Empty)).ParamName);

                Assert.Equal("transport",
                             Assert.Throws <ArgumentNullException>(
                                 () => UrlBuilder.BuildAbort(Mock.Of <IConnection>(), null, string.Empty)).ParamName);

                Assert.Equal("transport",
                             Assert.Throws <ArgumentNullException>(
                                 () => UrlBuilder.BuildAbort(Mock.Of <IConnection>(), string.Empty, string.Empty)).ParamName);

                Assert.Equal("transport",
                             Assert.Throws <ArgumentNullException>(
                                 () => UrlBuilder.BuildAbort(Mock.Of <IConnection>(), " ", string.Empty)).ParamName);
            }
예제 #4
0
 public void BuildAbortRetunsValidUrlWithConnectionData(string connectionData, string expected)
 {
     Assert.Equal(
         "http://fakeurl/abort?clientProtocol=1.42&transport=webPolling" + expected + "&connectionToken=My%20Conn%20Token",
         UrlBuilder.BuildAbort(CreateConnection(), "webPolling", connectionData));
 }