Esempio n. 1
0
        //public void Execute(Request request,
        //    Tcp.Params.Buffer receiveBufferSettings, Tcp.Params.Buffer sendBufferSettings)
        //{
        //    Execute(request, receiveBufferSettings, sendBufferSettings);
        //}

        public void Execute(Request request, 
            Tcp.Params.Buffer receiveBufferSettings, Tcp.Params.Buffer sendBufferSettings,
            HttpConnection.ConnectionDelegate onConnectCallback,
            HttpConnection.ConnectionDelegate onDisconnectCallback,
            HttpConnection.ErrorDelegate onErrorCallback,
            HttpConnection.ProgressDelegate onProgressCallback,
            HttpConnection.ConnectionDelegate onTimeoutCallback,
            HttpConnection.CompletionDelegate onCompleteCallback)
        {
            HttpConnection conn;

            conn = new HttpConnection(request.RequestLine.RequestUri, receiveBufferSettings, sendBufferSettings);

            if (onDisconnectCallback != null) conn.OnDisconnect += onDisconnectCallback;
            if (onErrorCallback != null) conn.OnError += onErrorCallback;
            if (onProgressCallback != null) conn.OnProgress += onProgressCallback;
            if (onTimeoutCallback != null) conn.OnTimeout += onTimeoutCallback;
            if (onCompleteCallback != null) conn.OnComplete += onCompleteCallback;

            conn.OnConnect += delegate(HttpConnection sender)
            {
                if (onConnectCallback != null) onConnectCallback(sender);
                conn.SendRequestAsync(request);
            };

            conn.ConnectAsync();

        }
Esempio n. 2
0
        void OnComplete(ClientLib.Client sender, Http.HttpConnection connection, Http.Response httpResponse, Api.Responses.ResponseBase apiResponse, TimeSpan duration)
        {
            Api.Responses.Pong resp = (Api.Responses.Pong)apiResponse;

            WriteLine("Server execution time: " + resp.Duration.Milliseconds.ToString() + "ms.");
            WriteLine("Round-trip completed in " + (DateTime.Now - _start).Milliseconds.ToString() + "ms.");
            WriteLine("JSON response:\r\n" + resp.FullContent.ToString());
        }
 public void ReleaseConnection(HttpConnection connection)
 {
     lock (_httpConnections)
     {
         if (_httpConnections.ContainsKey(connection.Uri))
         {
             _httpConnections.Remove(connection.Uri);
         }
     }
 }
        public HttpConnection GetConnection(Uri uri, int sendTimeout, int receiveTimeout,
            int sendBufferSize, int receiveBufferSize)
        {
            HttpConnection conn;

            lock (_httpConnections)
            {
                if (_httpConnections.ContainsKey(uri))
                {
                    conn = _httpConnections[uri];
                }
                else
                {
                    conn = new HttpConnection(uri, sendTimeout, receiveTimeout, sendBufferSize, receiveBufferSize);
                    _httpConnections.Add(uri, conn);
                }
            }

            return conn;
        }
Esempio n. 5
0
 void OnDisconnect(ClientLib.Client sender, Http.HttpConnection connection, TimeSpan duration)
 {
     WriteLine("Connection closed.");
 }
Esempio n. 6
0
 void OnError(ClientLib.Client sender, Http.HttpConnection connection, string message, Exception exception, TimeSpan duration)
 {
     WriteLine("Error - Message: " + message);
 }
Esempio n. 7
0
 void OnProgress(ClientLib.Client sender, Http.HttpConnection connection, Tcp.DirectionType direction, int packetSize, TimeSpan duration, decimal requestPercentSent, decimal responsePercentComplete)
 {
     WriteLine("Progress - Sent: " + requestPercentSent.ToString() + " Received: " + responsePercentComplete.ToString());
 }
Esempio n. 8
0
 void OnTimeout(ClientLib.Client sender, Http.HttpConnection connection, TimeSpan duration)
 {
     WriteLine("Timeout occurred.");
 }