Start() public method

Starts the Connection.
public Start ( ) : Task
return Task
Esempio n. 1
0
        static void Main(string[] args)
        {
            Task.Run(async () =>
            {
                var conHub = new HubConnection("http://localhost:8080/");
                conHub.CreateHubProxy("Shell").On<ShellCommandParams>("cmd", (data) =>
                {
                });

                using (var con = new Connection("http://localhost:8080/api/cmd"))
                {
                    con.Received += (data) =>
                    {
                        Console.WriteLine($"ola, recebi! {data}");
                    };
                    con.StateChanged += (state) =>
                    {
                        if (state.NewState != state.OldState)
                        {
                            Console.WriteLine($"De {state.OldState} para {state.NewState}");
                        }
                    };
                    await con.Start();

                    await con.Send("Hello Mello");
                }
            }).Wait();

        }
Esempio n. 2
0
 public RootControl()
 {
     InitializeComponent();
     XmlConfigurator.Configure();
     NetworkChange.NetworkAvailabilityChanged += (s, e) =>
     {
         Console.WriteLine(e.IsAvailable);
     };
     this.Loaded += (s, e) =>
     {
         connection = new Connection(AppConfig.Host + "/Connections/PadControl");
         connection.Received += Connection_Received;
         connection.StateChanged += Connection_StateChanged;
         connection.Closed += Connection_Closed;
         connection.ConnectionSlow += Connection_ConnectionSlow;
         connection.Start();
         if (!AppConfig.AutoScale)
         {
             Window window = Window.GetWindow(this);
             window.WindowState = WindowState.Normal;
             Int32Rect displayBounds = AppConfig.DisplayBound;
             window.Left = displayBounds.X;
             window.Top = displayBounds.Y;
             window.Width = displayBounds.Width;
             window.Height = displayBounds.Height;
         }
     };
  
 }
        private async Task RunPersistentConnection(string url, CookieContainer cookieContainer)
        {
            _traceWriter.WriteLine();
            _traceWriter.WriteLine("*** Persistent Connection ***");

            using (var connection = new Connection(url + "echo"))
            {
                connection.CookieContainer = cookieContainer;
                connection.TraceWriter = _traceWriter;

                connection.Received += data =>
                {
                    connection.TraceWriter.WriteLine("Received: " + data);
                };

                connection.Error += exception =>
                {
                    connection.TraceWriter.WriteLine("Error: {0}: {1}" + exception.GetType(), exception.Message);
                };

                await connection.Start();
                await connection.Send("sending to AuthorizeEchoConnection");
                await Task.Delay(TimeSpan.FromSeconds(2));
            }
        }
Esempio n. 4
0
        public ActivityClient( string ip, int port, IDevice device, bool useCache = true )
        {
            LocalCaching = useCache;

            InitializeEvents();

            Ip = ip;
            Port = port;

            Address = Net.GetUrl( ip, port, "" ).ToString();

            Device = device;

            try
            {
                _eventHandler = new Connection(Address);
                _eventHandler.JsonSerializer.TypeNameHandling = TypeNameHandling.Objects;
                _eventHandler.Received += eventHandler_Received;
                _eventHandler.Start().Wait();
            }
            catch(HttpClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 5
0
        public void NoReconnectsAfterFallback()
        {
            // There was a regression where the SSE transport would try to reconnect after it times out.
            // This test ensures that no longer happens.
            // #2180
            using (var host = new MemoryHost())
            {
                var myReconnect = new MyReconnect();

                host.Configure(app =>
                {
                    Func<AppFunc, AppFunc> middleware = (next) =>
                    {
                        return env =>
                        {
                            var request = new OwinRequest(env);
                            var response = new OwinResponse(env);

                            if (!request.Path.Value.Contains("negotiate") && !request.QueryString.Value.Contains("longPolling"))
                            {
                                response.Body = new MemoryStream();
                            }

                            return next(env);
                        };
                    };

                    app.Use(middleware);

                    var config = new ConnectionConfiguration
                    {
                        Resolver = new DefaultDependencyResolver()
                    };

                    config.Resolver.Register(typeof(MyReconnect), () => myReconnect);

                    app.MapSignalR<MyReconnect>("/echo", config);
                });

                var connection = new Connection("http://foo/echo");

                using (connection)
                {
                    connection.Start(host).Wait();

                    // Give SSE an opportunity to reconnect
                    Thread.Sleep(TimeSpan.FromSeconds(5));

                    Assert.Equal(connection.State, ConnectionState.Connected);
                    Assert.Equal(connection.Transport.Name, "longPolling");
                    Assert.Equal(0, myReconnect.Reconnects);
                }
            }
        }
Esempio n. 6
0
        public async Task RunAsync(string url)
        {
            _connection = new Connection(url);
            _connection.TraceWriter = _traceWriter;
            _connection.Received += (data) =>
            {
                _traceWriter.WriteLine("received: " + data);
            };

            await _connection.Start();
            await _connection.Send(new { Type = "sendToMe", Content = "Hello World!" });
        }
Esempio n. 7
0
        private void RunRawConnection(string serverUrl)
        {
            string url = serverUrl + "raw-connection";

            var connection = new Connection(url);
            connection.TraceWriter = _traceWriter;

            connection.Start().Wait();
            connection.TraceWriter.WriteLine("transport.Name={0}", connection.Transport.Name);

            connection.Send(new { type = 1, value = "first message" }).Wait();
            connection.Send(new { type = 1, value = "second message" }).Wait();
        }
        public void Setup()
        {
            _signalRReceived = new List<object>();
            _connection = new Connection("http://localhost:8989/signalr/rootfolder");
            _connection.Start(new LongPollingTransport()).ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Assert.Fail("SignalrConnection failed. {0}", task.Exception.GetBaseException());
                }
            });

            _connection.Received += _connection_Received;
        }
Esempio n. 9
0
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += (s, e) =>
            {
                connection = new Connection(AppConfig.Host + "/Connections/PadControl");
                connection.Received += Connection_Received;
                connection.StateChanged += Connection_StateChanged;
                connection.Closed += Connection_Closed;
                connection.ConnectionSlow += Connection_ConnectionSlow;
                connection.Start();
            };
        }
Esempio n. 10
0
        static void Connect(Microsoft.AspNet.SignalR.Client.Connection connection)
        {
            Logger.Info("SignalR: Starting connection");

            try
            {
                connection.Start(new LongPollingTransport()).Wait();
            }
            catch (Exception exception)
            {
                Logger.Error(MaybeAggregateException(exception),
                             "SignalR: Could not start connection");
                throw;
            }
        }
Esempio n. 11
0
        public ActionResult Test(string input)
        {
            // Connect to the service
            var connection = new Connection("http://squarepegio.apphb.com/echo");

            // Print the message when it comes in
            connection.Received += data => Console.WriteLine(data);

            // Start the connection
            connection.Start().Wait();

            connection.Send(input).Wait();

            return null;
        }
 public SignalRMessageBus(SignalRScaleoutConfiguration scaleoutConfiguration, IDependencyResolver dependencyResolver)
     : base(dependencyResolver, scaleoutConfiguration)
 {
     _connection = new Connection(scaleoutConfiguration.ServerUri.ToString());
     _connection.Closed += connectionOnClosed;
     _connection.Received += notificationRecieved;
     _connection.Error += onConnectionOnError;
     var startTask = _connection.Start();
     startTask.ContinueWith(t =>
         {
             if (t.IsFaulted && t.Exception != null)
                 throw t.Exception.GetBaseException();
         }, TaskContinuationOptions.OnlyOnFaulted);
     startTask.ContinueWith(_ => Open(streamIndex), TaskContinuationOptions.OnlyOnRanToCompletion);
 }
        private async Task RunPersistentConnection(string url, HttpClient httpClient, CookieContainer cookieContainer, string requestVerificationToken)
        {
            _traceWriter.WriteLine();
            _traceWriter.WriteLine("*** Persistent Connection ***");

            using (var connection = new Connection(url + "echo"))
            {
                connection.CookieContainer = cookieContainer;
                connection.TraceWriter = _traceWriter;
                connection.Received += (data) => connection.TraceWriter.WriteLine("Received: " + data);
                connection.Error += (exception) => connection.TraceWriter.WriteLine(string.Format("Error: {0}: {1}" + exception.GetType(), exception.Message));
                await connection.Start(GetClientTransport());
                await connection.Send("sending to AuthorizeEchoConnection");
                await Task.Delay(TimeSpan.FromSeconds(2));
            }
        }
        //leaving this as a compleately seperate system to event sending for now
        public static void Increment(string key)
        {
            // locking this operation so that it's thread safe
            if (incrementPersistantConnection == null)
            {
                lock (connectionLock)
                {
                    //Console.WriteLine("Creating new persistant connection");
                    incrementPersistantConnection = new Connection(connectionUrl + "events/increment");
                    incrementPersistantConnection.Start().Wait();
                    //Console.WriteLine("Connection created");
                }
            }

            incrementPersistantConnection.Send(key);
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            var connection = new Connection("http://localhost:3669/sensor/events");

            connection.Start().Wait();

            connection.AsObservable<SensorEvent>()
                .GroupBy(e => e.SensorId)
                .CombineLatest()
                .Select(latest => latest.Where(e => e.Reading > 0.75).ToList())
                .Where(latest => latest.Count() >= 2)
                .Subscribe(latest => Console.WriteLine("Sensors {0} show readings greater than 0.75", string.Join(",", latest.Select(e => e.SensorId))));

            Console.Read();

            connection.Stop();
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            // Connect to the service
            var connection = new Connection("http://localhost:6820/echo");

            // Print the message when it comes in
            connection.Received += data => Console.WriteLine(data);

            // Start the connection
            connection.Start().Wait();

            string line = null;
            while ((line = Console.ReadLine()) != null)
            {
                // Send a message to the server
                connection.Send(line).Wait();
            }
        }
 public async Task Start()
 {
     if (_conn != null)
     {
         return;
     }
     _conn = new Connection2(Urls.RealTimeMessaging);
     _conn.Headers["ak"]   = App.Apikey;
     _conn.Headers["e"]    = App.Environment.ToString();
     _conn.Received       += OnReceived;
     _conn.Closed         += OnClosed;
     _conn.ConnectionSlow += OnConnectionSlow;
     _conn.Error          += OnError;
     _conn.Reconnected    += OnReconnected;
     _conn.Reconnecting   += OnReconnecting;
     _conn.StateChanged   += OnStatechange;
     await _conn.Start();
 }
Esempio n. 18
0
        public static void Start()
        {
            const string url = "http://*****:*****@ {1}",connection.Url,DateTime.Now));
                                //Just a sample to test the concept
                                Thread.Sleep(2000);
                            }
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception);
                        }
                    }
                }));

            Console.ReadLine();
            //server.Dispose();
        }
 public SignalRMessageBus(SignalRScaleoutConfiguration scaleoutConfiguration, IDependencyResolver dependencyResolver)
     : base(dependencyResolver, scaleoutConfiguration)
 {
     _connection = new Connection(scaleoutConfiguration.ServerUri.ToString());
     _connection.Received += notificationRecieved;
     _connection.Error += e =>
         {
             Debug.WriteLine(e.ToString());
             OnError(0, e);
         };
     startTask = _connection.Start();
     startTask.ContinueWith(t =>
         {
             throw t.Exception.GetBaseException();
         }, TaskContinuationOptions.OnlyOnFaulted);
     startTask.ContinueWith(_ =>
         {
             Open(StreamIndex);
         }, TaskContinuationOptions.OnlyOnRanToCompletion);
 }
Esempio n. 20
0
        public ActivityClient( string ip, int port, IDevice device )
        {
            Ip = ip;
            Port = port;

            Address = Net.GetUrl( ip, port, "" ).ToString();

            Device = device;

            Initialize();

            try
            {
                _eventHandler = new Connection(Address);
                _eventHandler.Received += eventHandler_Received;
                _eventHandler.Start().Wait();
            }
            catch(HttpClientException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            try
            {
                var connection = new Connection("http://slabsignalrdemo.azurewebsites.net/semanticLogging");
                

                connection.Received += data =>
                    {
                        Console.WriteLine(data);
                    };

                connection.Start().ContinueWith(task =>
                {
                    if (task.IsFaulted)
                    {
                        Console.WriteLine("There was an error opening the connection:{0}",
                                          task.Exception.GetBaseException());
                    }
                    else
                    {
                        Console.WriteLine("Connected");
                    }

                }).Wait();

                connection.Error += Console.WriteLine;


            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.WriteLine("Press enter to close");
            Console.ReadLine();

        }
        public MainWindow()
        {
            InitializeComponent();

            var connection = new Connection("http://localhost:52029/echo");

            connection.Received += data =>
            {
                Console.WriteLine(data);
            };

            connection.Start().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Console.WriteLine("Failed to start: {0}", task.Exception.GetBaseException());
                }
                else
                {
                    Console.WriteLine("Success! Connected with client connection id {0}", connection.ConnectionId);
                    // Do more stuff here
                }
            });
        }
 public async Task Start()
 {
     if (_conn != null)
         return;
     _conn = new Connection2(Urls.RealTimeMessaging);
     _conn.Headers["ak"] = App.Apikey;
     _conn.Headers["e"] = App.Environment.ToString();
     _conn.Received += OnReceived;
     _conn.Closed += OnClosed;
     _conn.ConnectionSlow += OnConnectionSlow;
     _conn.Error += OnError;
     _conn.Reconnected += OnReconnected;
     _conn.Reconnecting += OnReconnecting;
     _conn.StateChanged += OnStatechange;
     await _conn.Start();
 }
Esempio n. 24
0
        private static Task ConnectBatch(string url, string transport, int batchSize, ConcurrentBag<Connection> connections)
        {
            var options = new ParallelOptions
            {
                MaxDegreeOfParallelism = batchSize
            };

            var batchTcs = new TaskCompletionSource<object>();

            long remaining = batchSize;
            Parallel.For(0, batchSize, options, async i =>
            {
                var connection = new Connection(url);

                if (!_running)
                {
                    batchTcs.TrySetResult(null);
                    return;
                }

                try
                {
                    var clientTransport = GetTransport(transport);
                    await (clientTransport == null ? connection.Start() : connection.Start(clientTransport));

                    if (_running)
                    {
                        connections.Add(connection);

                        var clientId = connection.ConnectionId;

                        connection.Error += e =>
                        {
                            Debug.WriteLine(String.Format("SIGNALR: Client {0} ERROR: {1}", clientId, e));
                        };

                        connection.Closed += () =>
                        {
                            Debug.WriteLine(String.Format("SIGNALR: Client {0} CLOSED", clientId));

                            // Remove it from the list on close
                            connections.TryTake(out connection);
                        };
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to start client. {0}", ex.GetBaseException());
                }
                finally
                {
                    if (Interlocked.Decrement(ref remaining) == 0)
                    {
                        // When all connections are connected, mark the task as complete
                        batchTcs.TrySetResult(null);
                    }
                }
            });

            return batchTcs.Task;
        }
Esempio n. 25
0
        protected void ConnectSignalR()
        {
            _signalRReceived = new List<SignalRMessage>();
            _signalrConnection = new Connection("http://localhost:8989/signalr");
            _signalrConnection.Start(new LongPollingTransport()).ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Assert.Fail("SignalrConnection failed. {0}", task.Exception.GetBaseException());
                }
            });

            var retryCount = 0;

            while (_signalrConnection.State != ConnectionState.Connected)
            {
                if (retryCount > 25)
                {
                    Assert.Fail("Couldn't establish signalr connection. State: {0}", _signalrConnection.State);
                }

                retryCount++;
                Console.WriteLine("Connecting to signalR" + _signalrConnection.State);
                Thread.Sleep(200);
            }

            _signalrConnection.Received += json => _signalRReceived.Add(Json.Deserialize<SignalRMessage>(json)); ;
        }
Esempio n. 26
0
        private async Task RunAuth(string serverUrl)
        {
            string url = serverUrl + "cookieauth";

            var handler = new HttpClientHandler();
            handler.CookieContainer = new CookieContainer();
            using (var httpClient = new HttpClient(handler))
            {
                var content = string.Format("UserName={0}&Password={1}", "user", "password");
                var response = httpClient.PostAsync(url + "/Account/Login", new StringContent(content, Encoding.UTF8, "application/x-www-form-urlencoded")).Result;
            }

            var connection = new Connection(url + "/echo");
            connection.TraceWriter = _traceWriter;
            connection.Received += (data) => connection.TraceWriter.WriteLine(data);
#if !ANDROID && !iOS
            connection.CookieContainer = handler.CookieContainer;
#endif
            await connection.Start();
            await connection.Send("sending to AuthenticatedEchoConnection");

            var hubConnection = new HubConnection(url);
            hubConnection.TraceWriter = _traceWriter;
#if !ANDROID && !iOS
            hubConnection.CookieContainer = handler.CookieContainer;
#endif
            var hubProxy = hubConnection.CreateHubProxy("AuthHub");
            hubProxy.On<string, string>("invoked", (connectionId, date) => hubConnection.TraceWriter.WriteLine("connectionId={0}, date={1}", connectionId, date));

            await hubConnection.Start();
            hubConnection.TraceWriter.WriteLine("transport.Name={0}", hubConnection.Transport.Name);

            await hubProxy.Invoke("InvokedFromClient");
        }
Esempio n. 27
0
        private async Task RunStreaming(string serverUrl)
        {
            string url = serverUrl + "streaming-connection";

            var connection = new Connection(url);
            connection.TraceWriter = _traceWriter;

            await connection.Start();
            connection.TraceWriter.WriteLine("transport.Name={0}", connection.Transport.Name);
        }
        private void Action_Click(object sender, RoutedEventArgs e)
        {
            msgTxtBlock.Text = "";

            if (Action.Content.ToString() == "Start")
            {
                // Read the signalrPortNumber
                // The signalrClient will be listening at this port number
                string signalrPortNumber = Utilities.GetAppsettingsValue("signalrPortNumber");
                string signalrServer = "http://localhost:" + signalrPortNumber + "/listener";

                if (tracingEnabled == true)
                {
                    signalRConnectionProgressBar.Visibility = System.Windows.Visibility.Visible;
                    DisplayMessage("Connecting ...",false);
                    signalrConnectionTimer.Start();
                    connectionTimedOut = false;

                    if (connection == null)
                    {
                        connection = new Connection(signalrServer);
                        try
                        {
                            connection.Start();
                        }
                        catch(Exception ex)
                        {
                            if (Utilities.GetAppsettingsValue("displayErrors") == "True")
                                DisplayMessage("Error while starting the listener: " + ex.Message,true);
                            return;
                        }

                        connection.Received += data =>
                        {
                            //if (tracingEnabled == false)
                            //{
                            //    // This can happen if user has disabled tracing without stopping the trace
                            //    StopTracing();
                            //}

                            if (tracingStarted)
                            {

                                XElement traceXml = XElement.Parse(data.ToString());
                                System.Xml.Linq.XNode firstNode = traceXml.FirstNode;
                                if (firstNode.ToString().Contains("MessageLogTraceRecord"))
                                {
                                    AddMessageItem(traceXml);
                                }
                                else
                                {
                                    AddTraceItem(traceXml);
                                }
                            }

                        };
                        connection.Closed += connection_closed;
                        connection.StateChanged += connection_StateChanged;
                    }
                    else
                    {
                        connection.Start();
                    }

                    Action.Content = "Stop";
                    tracingStarted = true;
                }
                else
                {
                    // tracing is not enabled. Prompt the user to configure tracing
                    DisplayMessage("Please select a WCF application to trace and then click Start",true);
                }
            }
            else
            {
                StopTracing();
            }
        }
Esempio n. 29
0
        private void RunBasicAuth(string serverUrl)
        {
            string url = serverUrl + "basicauth";

            var connection = new Connection(url + "/echo");
            connection.TraceWriter = _traceWriter;
            connection.Received += (data) => connection.TraceWriter.WriteLine(data);
            connection.Credentials = new NetworkCredential("user", "password");
            connection.Start().Wait();
            connection.Send("sending to AuthenticatedEchoConnection").Wait();

            var hubConnection = new HubConnection(url);
            hubConnection.TraceWriter = _traceWriter;
            hubConnection.Credentials = new NetworkCredential("user", "password");

            var hubProxy = hubConnection.CreateHubProxy("AuthHub");
            hubProxy.On<string, string>("invoked", (connectionId, date) => hubConnection.TraceWriter.WriteLine("connectionId={0}, date={1}", connectionId, date));

            hubConnection.Start().Wait();
            hubConnection.TraceWriter.WriteLine("transport.Name={0}", hubConnection.Transport.Name);

            hubProxy.Invoke("InvokedFromClient").Wait();
        }
Esempio n. 30
0
        public static IDisposable ClientGroupsSyncWithServerGroupsOnReconnectLongPolling()
        {
            var host = new MemoryHost();

            host.Configure(app =>
            {
                var config = new ConnectionConfiguration()
                {
                    Resolver = new DefaultDependencyResolver()
                };

                app.MapConnection<MyRejoinGroupConnection>("/groups", config);

                var configuration = config.Resolver.Resolve<IConfigurationManager>();
                configuration.KeepAlive = null;
                configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
            });

            var connection = new Client.Connection("http://foo/groups");
            var inGroupOnReconnect = new List<bool>();
            var wh = new ManualResetEventSlim();

            connection.Received += message =>
            {
                Console.WriteLine(message);
                wh.Set();
            };

            connection.Reconnected += () =>
            {
                connection.Send(new { type = 3, group = "test", message = "Reconnected" }).Wait();
            };

            connection.Start(new Client.Transports.LongPollingTransport(host)).Wait();

            // Join the group
            connection.Send(new { type = 1, group = "test" }).Wait();

            Thread.Sleep(TimeSpan.FromSeconds(10));

            if (!wh.Wait(TimeSpan.FromSeconds(10)))
            {
                Debugger.Break();
            }

            Console.WriteLine(inGroupOnReconnect.Count > 0);
            Console.WriteLine(String.Join(", ", inGroupOnReconnect.Select(b => b.ToString())));

            connection.Stop();

            return host;
        }
Esempio n. 31
0
        private static void BroadcastFive(MemoryHost host)
        {
            var connection = new Client.Connection("http://samples/Raw-connection");

            connection.Error += e =>
            {
                Console.Error.WriteLine("========ERROR==========");
                Console.Error.WriteLine(e.GetBaseException().ToString());
                Console.Error.WriteLine("=======================");
            };

            connection.Start(new Client.Transports.ServerSentEventsTransport(host)).Wait();

            try
            {
                for (int i = 0; i < 5; i++)
                {
                    var payload = new
                    {
                        type = MessageType.Broadcast,
                        value = "message " + i.ToString()
                    };

                    connection.Send(payload).Wait();
                }

            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("========ERROR==========");
                Console.Error.WriteLine(ex.GetBaseException().ToString());
                Console.Error.WriteLine("=======================");
            }
            finally
            {
                connection.Stop();
            }
        }
Esempio n. 32
0
        private void RunAuth(string serverUrl)
        {
            string url = serverUrl + "cookieauth";

            var cookieContainer = new CookieContainer();
            var request = (HttpWebRequest)HttpWebRequest.Create(url + "/Account/Login");
            request.CookieContainer = cookieContainer;
            request.ContentType = "application/x-www-form-urlencoded";
            request.Method = "POST";

            var content = string.Format("UserName={0}&Password={1}", "user", "password");
            byte[] bytedata = Encoding.UTF8.GetBytes(content);
            request.ContentLength = bytedata.Length;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(bytedata, 0, bytedata.Length);
            requestStream.Close();
            var response = request.GetResponse();

            var connection = new Connection(url + "/echo");
            connection.TraceWriter = _traceWriter;
            connection.Received += (data) => connection.TraceWriter.WriteLine(data);
            connection.CookieContainer = cookieContainer;
            connection.Start().Wait();
            connection.Send("sending to AuthenticatedEchoConnection").Wait();

            var hubConnection = new HubConnection(url);
            hubConnection.TraceWriter = _traceWriter;
            hubConnection.CookieContainer = cookieContainer;

            var hubProxy = hubConnection.CreateHubProxy("AuthHub");
            hubProxy.On<string, string>("invoked", (connectionId, date) => hubConnection.TraceWriter.WriteLine("connectionId={0}, date={1}", connectionId, date));

            hubConnection.Start().Wait();
            hubConnection.TraceWriter.WriteLine("transport.Name={0}", hubConnection.Transport.Name);

            hubProxy.Invoke("InvokedFromClient").Wait();
        }