コード例 #1
0
    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;
        }
    }
コード例 #2
0
ファイル: SKAPIEvent.cs プロジェクト: hipo760/QuoteService
        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)));
        }
コード例 #3
0
 public override void DispatchStatus(DeviceStatus status)
 {
     ConnectionStatusEvent?.Invoke(new ConnectionStatusEventArgs()
     {
         Status = status,
         Ip     = Ip,
         Type   = TypeDevice
     });
 }
コード例 #4
0
 public override void DispatchStatus(DeviceStatus status)
 {
     ConnectionStatusEvent?.Invoke(new ConnectionStatusEventArgs
     {
         Status = status,
         //TODO: ComPortAddress
         ComPort = "Unknown",
         Type    = TypeDevice
     });
 }
コード例 #5
0
 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.
     }
 }
コード例 #6
0
 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.
     }
 }
コード例 #7
0
        /// <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
        }
コード例 #8
0
 /// <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();
     }
 }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
 public void HandleConnectionStatusEvent(object sender, ConnectionStatusEvent connectionStatusEvent)
 {
     System.Console.WriteLine($"ConnectionStatus: {connectionStatusEvent.Type}");
 }
コード例 #11
0
 public void HandleConnectionStatusEvent(object sender, ConnectionStatusEvent connectionStatusEvent)
 {
     Debug.WriteLine($"ConnectionStatus: {connectionStatusEvent.Type}");
 }
コード例 #12
0
 public void Handle(ConnectionStatusEvent message)
 {
 }