public void OnConnectionStatusReport(string status) { switch (status) { case "con": currentStatus = ConnectionStatus.STATUS_CONNECTING; ConnectionStatusEvent?.Invoke(ConnectionStatus.STATUS_CONNECTING); break; case "ctd": currentStatus = ConnectionStatus.STATUS_CONNECTED; ConnectionStatusEvent?.Invoke(ConnectionStatus.STATUS_CONNECTED); break; case "err": //GOt an exception while trying to connect currentStatus = ConnectionStatus.STATUS_FAILED; ConnectionStatusEvent?.Invoke(ConnectionStatus.STATUS_FAILED); break; case "dis": //Got an exception in socket or stream after establising a successful connection currentStatus = ConnectionStatus.STATUS_DISCONNECTED; ConnectionStatusEvent?.Invoke(ConnectionStatus.STATUS_DISCONNECTED); break; } }
private void UpdateConnectionStatus(int nkind, int ncode) { _logger.Debug("[SKAPIConnection.SkQuotes_OnConnection()] {nkind}", nkind); switch (nkind) { case 3001: _skStatus = ConnectionStatus.Connecting; break; case 3003: _skStatus = ConnectionStatus.ConnectionReady; break; case 3002: case 3021: _skStatus = ConnectionStatus.NotConnected; break; case 3022: _skStatus = ConnectionStatus.ConnectionError; break; default: _skStatus = ConnectionStatus.Unknown; break; } _connStatusBroker.Publish(ConnectionStatusEvent.GetEvent(_skStatus, _skapi.SKCenterLib_GetReturnCodeMessage(nkind))); }
public override void DispatchStatus(DeviceStatus status) { ConnectionStatusEvent?.Invoke(new ConnectionStatusEventArgs() { Status = status, Ip = Ip, Type = TypeDevice }); }
public override void DispatchStatus(DeviceStatus status) { ConnectionStatusEvent?.Invoke(new ConnectionStatusEventArgs { Status = status, //TODO: ComPortAddress ComPort = "Unknown", Type = TypeDevice }); }
public void OnConnectionStatusChange(ConnectionStatusEvent statusEvent) { if (statusEvent.Status == ConnectionStatus.Connected) { // Notify the user in some way - update the status bar, have a "light" that toggles green or something. } else { // Notify the user in some way - update the status bar, have a "light" that toggles red or something. } }
/// <summary> /// Event notification for completion of TT API shutdown /// </summary> private void ShutdownCompleted(object sender, EventArgs e) { // Shutdown the Dispatcher if (_disp != null) { _disp.InvokeShutdown(); _disp = null; } ConnectionStatusEvent?.Invoke(this, "Connection_Down"); // Dispose of any other objects / resources }
/// <summary> /// Event notification for status of authentication /// </summary> private void AuthenticationStatusUpdate(object sender, AuthenticationStatusUpdateEventArgs e) { if (e.Status.IsSuccess) { log.Info("TT Login Succed"); ConnectionStatusEvent?.Invoke(this, "Connection_Succeed"); } else { log.Info($"TT Login failed: {e.Status.StatusMessage}"); ConnectionStatusEvent?.Invoke(this, "Connection_Failed"); Dispose(); } }
public async Task CreateConnection() { _connection = new HubConnectionBuilder().WithUrl("http://localhost:51568/demo").Build(); _connection.On <DemoMessage>("pump", message => { MessageReceived?.Invoke(this, message.Id + " message: " + message.Message); }); _connection.On <string>("success", message => { MessageReceived?.Invoke(this, message); }); _connection.On <string>("failed", message => { MessageReceived?.Invoke(this, message); }); _connection.Closed += async(err) => { ConnectionStatusEvent?.Invoke(this, "disconnected with error: " + err.Message); await _connection.StartAsync(); ConnectionStatusEvent?.Invoke(this, "retrying connection"); }; try { await _connection.StartAsync(); ConnectionStatusEvent?.Invoke(this, "initial connection begun"); await _connection.SendAsync("setup", "secret"); } catch (Exception e) { ConnectionStatusEvent?.Invoke(this, "disconnected with error: " + e.Message); throw; } }
public void HandleConnectionStatusEvent(object sender, ConnectionStatusEvent connectionStatusEvent) { System.Console.WriteLine($"ConnectionStatus: {connectionStatusEvent.Type}"); }
public void HandleConnectionStatusEvent(object sender, ConnectionStatusEvent connectionStatusEvent) { Debug.WriteLine($"ConnectionStatus: {connectionStatusEvent.Type}"); }
public void Handle(ConnectionStatusEvent message) { }