예제 #1
0
 public async Task Connect()
 {
     var http = new Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient();
     //var transports = new List<IClientTransport>()
     //                                                        {
     //                                                            new WebSocketTransportLayer(http),
     //                                                            new ServerSentEventsTransport(http),
     //                                                            new LongPollingTransport(http)
     //                                                        };
     /// Preparando la conexion
     //await _connection.Start(new AutoTransport(http, transports));
     await _connection.Start(new WebSocketTransportLayer(http));
 }
예제 #2
0
        public async Task Connect()
        {
            var http = new Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient();

            if (Application.Current.Properties.ContainsKey("username"))
            {
                _username = Application.Current.Properties["username"] as string;
                _connection.Headers["username"] = _username;
            }
            if (!string.IsNullOrEmpty(_username))
            {
                if (_connection != null && _connection.State != ConnectionState.Connected)
                {
                    await _connection.Start(http);
                }
                if (_connection != null && _connection.State == ConnectionState.Connected)
                {
                    await UpdateUsersOnAllClients();
                }
            }
        }