protected override void OnStart(IConnection connection, string connectionData, CancellationToken disconnectToken, TransportInitializationHandler initializeHandler) { var requestHandler = new PollingRequestHandler(HttpClient); var negotiateInitializer = new NegotiateInitializer(initializeHandler); Action <IRequest> initializeAbort = request => { negotiateInitializer.Abort(disconnectToken); }; requestHandler.OnError += negotiateInitializer.Complete; requestHandler.OnAbort += initializeAbort; // If the transport fails to initialize we want to silently stop initializeHandler.OnFailure += () => { requestHandler.Stop(); }; // Once we've initialized the connection we need to tear down the initializer functions and assign the appropriate onMessage function negotiateInitializer.Initialized += () => { requestHandler.OnError -= negotiateInitializer.Complete; requestHandler.OnAbort -= initializeAbort; }; // Add additional actions to each of the PollingRequestHandler events PollingSetup(connection, connectionData, disconnectToken, requestHandler, negotiateInitializer.Complete); requestHandler.Start(); }
protected override void OnStart(IConnection connection, string connectionData, CancellationToken disconnectToken, TransportInitializationHandler initializeHandler) { var requestHandler = new PollingRequestHandler(HttpClient); var negotiateInitializer = new NegotiateInitializer(initializeHandler); Action<IRequest> initializeAbort = request => { negotiateInitializer.Abort(disconnectToken); }; requestHandler.OnError += negotiateInitializer.Complete; requestHandler.OnAbort += initializeAbort; // If the transport fails to initialize we want to silently stop initializeHandler.OnFailure += () => { requestHandler.Stop(); }; // Once we've initialized the connection we need to tear down the initializer functions and assign the appropriate onMessage function negotiateInitializer.Initialized += () => { requestHandler.OnError -= negotiateInitializer.Complete; requestHandler.OnAbort -= initializeAbort; }; // Add additional actions to each of the PollingRequestHandler events PollingSetup(connection, connectionData, disconnectToken, requestHandler, negotiateInitializer.Complete); requestHandler.Start(); }
protected override void OnStart(IConnection connection, string data, CancellationToken disconnectToken, Action initializeCallback, Action <Exception> errorCallback) { var requestHandler = new PollingRequestHandler(HttpClient); var negotiateInitializer = new NegotiateInitializer(initializeCallback, errorCallback, ConnectDelay); // Save the success and abort cases so we can remove them after transport is initialized Action <string> initializeSuccess = message => { negotiateInitializer.Complete(); }; Action <IRequest> initializeAbort = request => { negotiateInitializer.Abort(disconnectToken); }; requestHandler.OnMessage += initializeSuccess; requestHandler.OnError += negotiateInitializer.Complete; requestHandler.OnAbort += initializeAbort; // Once we've initialized the connection we need to tear down the initializer functions negotiateInitializer.Initialized += () => { requestHandler.OnMessage -= initializeSuccess; requestHandler.OnError -= negotiateInitializer.Complete; requestHandler.OnAbort -= initializeAbort; }; // Add additional actions to each of the PollingRequestHandler events PollingSetup(connection, data, disconnectToken, requestHandler); requestHandler.Start(); // Start initialization, essentially if we have an assume sucess clause in our negotiateInitializer // then we will start the countdown from the point which we start initialization. negotiateInitializer.Initialize(); }
protected override void OnStart(IConnection connection, string data, CancellationToken disconnectToken, Action initializeCallback, Action<Exception> errorCallback) { var requestHandler = new PollingRequestHandler(HttpClient); var negotiateInitializer = new NegotiateInitializer(initializeCallback, errorCallback, ConnectDelay); // Save the success and abort cases so we can remove them after transport is initialized Action<string> initializeSuccess = message => { negotiateInitializer.Complete(); }; Action<IRequest> initializeAbort = request => { negotiateInitializer.Abort(disconnectToken); }; requestHandler.OnMessage += initializeSuccess; requestHandler.OnError += negotiateInitializer.Complete; requestHandler.OnAbort += initializeAbort; // Once we've initialized the connection we need to tear down the initializer functions negotiateInitializer.Initialized += () => { requestHandler.OnMessage -= initializeSuccess; requestHandler.OnError -= negotiateInitializer.Complete; requestHandler.OnAbort -= initializeAbort; }; // Add additional actions to each of the PollingRequestHandler events PollingSetup(connection, data, disconnectToken, requestHandler); requestHandler.Start(); // Start initialization, essentially if we have an assume sucess clause in our negotiateInitializer // then we will start the countdown from the point which we start initialization. negotiateInitializer.Initialize(); }