Ejemplo n.º 1
0
        private async Task <bool> TryStart()
        {
            try
            {
                await connection.Start().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                log.Write(LogVerbosity.Warning, $"Couldn't connect. {ex.GetType()}");
                log.Write(LogVerbosity.Debug, $" {ex.Message}");
                return(false);
            }

            log.Write(LogVerbosity.Info, "Socket connection established");

            // subscribe to all market deltas
            await proxy.Invoke(MarketDeltaSub).ConfigureAwait(false);

            IEnumerable <BittrexExchangeDeltasRegistration> marketRegistrations;

            lock (registrationLock)
                marketRegistrations = registrations.OfType <BittrexExchangeDeltasRegistration>();

            foreach (var registration in marketRegistrations)
            {
                await SubscribeToExchangeDeltas(registration.MarketName).ConfigureAwait(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 private IObservable <Unit> StartConnectionAction()
 {
     return(m_hubConnection
            .Start()
            .Catch <Unit, Exception>(ex =>
     {
         Debug.LogException(ex);
         return Observable.Never(Unit.Default);
     })
            .ContinueWith(_ =>
     {
         Debug.Log($"{nameof(BootstrapTree)}: the connection was open!");
         return Observable.ReturnUnit();
     }));
 }
Ejemplo n.º 3
0
        private async Task <bool> TryStart()
        {
            try
            {
                await connection.Start().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                log.Write(LogVerbosity.Warning, $"Couldn't connect. {ex.GetType()}");
                log.Write(LogVerbosity.Debug, $" {ex.Message}");
                return(false);
            }

            log.Write(LogVerbosity.Info, "Socket connection established");
            return(true);
        }
Ejemplo n.º 4
0
 public void ConnectToServer()
 {
     _hubProxy = _hubConnection.CreateHubProxy("MessageHub");                    // must match hub name
     _hubProxy.On <DateTime>("ReceiveMessage", ReceiveMessage);
     _hubConnection.Start();
 }