public void Connect(HTransportOptions options) { this.connStatus = ConnectionStatus.CONNECTING; this.options = options; //TODO init the connection timeout value!! connTimeout = new TimeSpan(0, 0, 0, 0, options.Timeout); string endpointHost = options.EndpointHost; int endpointPort = options.EndpointPort; string endpointPath = options.EndpointPath; string endpointAdress = ToEndpointAdress(endpointHost, endpointPort, endpointPath); connTimeoutTimer = ThreadPoolTimer.CreateTimer(timeout_Elapsed, connTimeout); socketIO = new Client(endpointAdress); socketIO.Message += socketIO_Message; socketIO.SocketConnectionClosed += socketIO_SocketConnectionClosed; socketIO.Error += socketIO_Error; socketIO.On("connect", (message) => { if (this.options.AuthCb != null) this.options.AuthCb(options.Login, Login); else Login(options.Login, options.Password); }); socketIO.ConnectAsync(); }
public void DisplayStatus(ConnectionStatus status) { _notificator.Visibility = Visibility.Visible; _notificator.Source = new BitmapImage(new Uri("ms-appx:///Assets/"+status+".png")); _timer.Start(); }
public void Update() { if (_connectStarted.Elapsed.TotalSeconds > 120) { if (_bot != null) _bot.Disconnect(); Status = ConnectionStatus.Disconnected; } if (Status != ConnectionStatus.Disconnected) return; _hasConnected = false; _connectStarted.Restart(); Program.Logger.Info("Connecting"); _bot = new SteamBot(Program.Settings.Username, Program.Settings.Password, Program.Settings.AuthCode); _bot.OnConnected += sender => { _hasConnected = true; _connectStarted.Stop(); _bot.DisplayName = Program.Settings.PersonaName; _bot.PersonaState = EPersonaState.Online; Status = ConnectionStatus.Connected; Program.Logger.Info("Connected"); }; _bot.OnDisconnected += (sender, reason) => { if (reason == SteamBotDisconnectReason.SteamGuard) Thread.Sleep(TimeSpan.FromMinutes(2)); // TODO: need a better way of entering steamguard auth if (_hasConnected) { Program.Logger.InfoFormat("Disconnected {0}", reason); _hasConnected = false; } Status = ConnectionStatus.Disconnected; }; _bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id); _bot.OnPrivateEnter += (sender, chat) => { chat.OnMessage += (chatSender, messageSender, message) => Command.Handle(new CommandTarget(chatSender, messageSender), message, ""); }; _bot.OnChatInvite += (sender, chat, @by) => { if (chat.Id.IsIndividualAccount) _bot.Join(chat.Id); }; _bot.Connect(); Status = ConnectionStatus.Connecting; }
private void OnConnectionStatus_callback(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { if (null != OnConnectionStatus) { OnConnectionStatus(this, new OnConnectionStatusEventArgs(status, ref userLogin, size1)); } }
/// <summary> /// Public constructor for createing a Client object /// </summary> /// <param name="iSocket">Socket associated with the Client object</param> /// <param name="iClientStreamIndex">Index number of the associated Client object</param> public ClientStream(Socket iSocket, int iClientStreamIndex) { Socket = iSocket; Index = iClientStreamIndex; ConnectionStatus = ConnectionStatus.Pending; OnClientConnect(); }
public void SetResult(ConnectionStatus status) { if (!_enabled) return; this._result = status; this._stopwatch.Stop(); }
public lokunclientform() { InitializeComponent(); lokun = Lokun.instance; connected = ConnectionStatus.NotRunning; chkAutostart.Checked = lokun.Autostart; btnDownload.Enabled = false; switch(lokun.UserRoutingSetting) { case RoutingSetting.Everything: rdTunnelEverything.Checked = true; break; case RoutingSetting.ExcludeISNets: rdExcludeIcelandic.Checked = true; break; case RoutingSetting.OnlyISNets: rdOnlyIcelandic.Checked = true; break; } StartStopSetUI(lokun.OpenVPNServiceIsRunning); var username = lokun.GetCurrentUsername(); if (username != null) { txtUsername.Text = username; txtPassword.Text = "hunter2"; //ststrpLabel.Text = "Current account: " + username; } }
/// <summary> /// Initializes a new instance of the <see cref="ProScanMobile.NetworkConnection"/> class. /// </summary> /// <description> /// Creates a new _tcpSocket and tries to connect to Host/Port /// </description> /// <param name="host">Host</param> /// <param name="port">Port</param> public NetworkConnection(string host, int port) { _connectDone.Reset (); try { IPHostEntry ipHostInfo = Dns.GetHostEntry (host); IPAddress ipAddress = ipHostInfo.AddressList [0]; IPEndPoint remoteEP = new IPEndPoint (ipAddress, port); _tcpSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _tcpSocket.Blocking = true; var result = _tcpSocket.BeginConnect (remoteEP, null, null); bool success = result.AsyncWaitHandle.WaitOne (5000, true); if (success) { _tcpSocket.EndConnect (result); _connectionStatus = ConnectionStatus.Connected; _connectionStatusMessage = "Connected."; } else { _tcpSocket.Close (); _connectionStatus = ConnectionStatus.Error; _connectionStatusMessage = "Connection timed out."; } } catch { _connectionStatus = ConnectionStatus.Error; _connectionStatusMessage = string.Format("An error occured connecting to {0} on port {1}.", host, port); _connectDone.Set(); return; } finally { _connectDone.Set (); } }
private async void btnCheckConnection_Click(object sender, EventArgs e) { lblCheckConnection.Text = "Checking..."; lblCheckConnection.Refresh(); connected = await lokun.FullyCheckConnectionStatusAsync(); if (connected == ConnectionStatus.EverythingTunneled) { lblCheckConnection.Text = "Tunnel active"; } else if (connected == ConnectionStatus.ConnectedWithoutDGW) { lblCheckConnection.Text = "Tunnel idle"; } else if (connected == ConnectionStatus.RunningNotConnected) { lblCheckConnection.Text = "Tunnel not in use"; } else if (connected == ConnectionStatus.OpenVPNNotInstalled) { lblCheckConnection.Text = "Error: OpenVPN missing"; } else { lblCheckConnection.Text = "Tunnel down"; } lblCheckConnection.Refresh(); }
protected internal AuthenticationResult AbortedAuthentication(string message, ConnectionStatus status = ConnectionStatus.Faulted) { return new AuthenticationResult { Status = status, Message = message, }; }
public NetworkStatus(ConnectionStatus connectionStatus, ConnectionProtocolType protocolType, TCPRole tcpRole, int clientCount, string classroomName) { this.ConnectionStatus = connectionStatus; this.ProtocolType = protocolType; this.TCPRole = tcpRole; this.ClientCount = clientCount; this.ClassroomName = classroomName; }
//public fnOnRtnForQuoteRsp OnRtnForQuoteRsp //{ // set // { // OnRtnForQuoteRsp_1 = value; // OnRtnForQuoteRsp_2 = OnRtnForQuoteRsp_3; // MdApi.CTP_RegOnRtnForQuoteRsp(_MsgQueue.Queue, OnRtnForQuoteRsp_2); // } //} //private void OnRtnForQuoteRsp_3(IntPtr pMdUserApi, ref CThostFtdcForQuoteRspField pForQuoteRsp) //{ // OnRtnForQuoteRsp_1(this, pMdUserApi, ref pForQuoteRsp); //} protected override void OnConnect_3(IntPtr pApi, ref CThostFtdcRspUserLoginField pRspUserLogin, ConnectionStatus result) { IsConnected = false; if (result == ConnectionStatus.Logined) { IsConnected = true; } OnConnect_1(this, pApi, ref pRspUserLogin, result); }
public void Update() { if (_connectStarted.Elapsed.TotalSeconds > 120) { if (_bot != null) _bot.Disconnect(); Status = ConnectionStatus.Disconnected; } if (Status != ConnectionStatus.Disconnected) return; _hasConnected = false; _connectStarted.Restart(); Program.Logger.Info("Connecting"); _bot = new Bot(Program.Settings.Username, Program.Settings.Password); _bot.OnConnected += sender => { _hasConnected = true; _connectStarted.Stop(); _bot.PersonaName = Program.Settings.PersonaName; _bot.PersonaState = EPersonaState.Online; Status = ConnectionStatus.Connected; Program.Logger.Info("Connected"); }; _bot.OnDisconnected += (sender, reason) => { if (_hasConnected) { Program.Logger.Info("Disconnected"); _hasConnected = false; } Status = ConnectionStatus.Disconnected; }; _bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id); _bot.OnPrivateEnter += (sender, chat) => { chat.OnMessage += (chatSender, messageSender, message) => Command.Handle(new CommandTarget(chatSender, messageSender.Id), message, ""); }; _bot.OnChatInvite += (sender, chat, @by) => { if (chat.Id.IsIndividualAccount) _bot.Join(chat.Id); }; _bot.Connect(); Status = ConnectionStatus.Connecting; }
/// <summary> /// Public constructor for createing a Server object /// </summary> /// <param name="iSocket">Socket associated with Server object</param> /// <param name="iServerInfoIndex">Index number of the associated Server object</param> public ServerInfo(Socket iSocket, int iServerInfoIndex, ConnectionInfo iConnectionInfo, ConnectionMode iConnectionMode) { Socket = iSocket; Index = iServerInfoIndex; ConnectionInfo = iConnectionInfo; ConnectionMode = iConnectionMode; ConnectionStatus = ConnectionStatus.Pending; OnServerConnect(); }
public void ClientStatusUpdate(ConnectionStatus cs, string msg) { if (cs == ConnectionStatus.Connected) { RunOnUiThread(() => Toast.MakeText(this, "Connected to Server", ToastLength.Short).Show()); } else { RunOnUiThread(() => Toast.MakeText(this, "Could not connect to server", ToastLength.Short).Show()); } }
static void OnConnectionStatus2(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { if (size1 > 0) { Console.WriteLine("222222" + userLogin.ToFormattedStringLong()); } else { Console.WriteLine("222222" + status); } }
internal Connection(CapiApplication application, Controller controller, uint plci, string calledPartyNumber, string callingPartyNumber) { _dtfmDuration = 40; _dtfmPause = 40; _application = application; _controller = controller; _plci = plci; _calledPartyNumber = calledPartyNumber; _callingPartyNumber = callingPartyNumber; _status = ConnectionStatus.Disconnected; }
public HttpResponse(ConnectionStatus status, String Connection, String filePath) { cookies = new Dictionary<String, String>(); headers = new Dictionary<String, String>(); this.status = status; this.filePath = filePath; //headers.Add("Allow", "GET"); headers.Add("Date", DateTime.Now.ToString("r")); headers.Add("Server", "MyMobiControllerServer"); headers.Add("Connection", Connection); }
public void Start(Socket socket) { lock (lockObject) { TcpSocket = socket; _tcpOffset = 0; Status = ConnectionStatus.Connected; _messageInQueue = new BlockingCollection<IMessage>(); _messageOutQueue = new BlockingCollection<IMessage>(); BeginReading(); BeginSending(); } }
public void Close() { Debug.Assert(Status == ConnectionStatus.Opend, "Connection.Close: Status must be Opened."); if (Status == ConnectionStatus.Opend) { try { while (_transactions.Count > 0) _transactions[0].Dispose(); Status = ConnectionStatus.Closed; } catch { } } }
/// <summary> /// Initializes a new instance of the <see cref="NetworkStatus"/> class. /// </summary> public NetworkStatus() { bool online = NetworkInterface.GetIsNetworkAvailable(); ConnectionStatus current = online ? ConnectionStatus.Connected : ConnectionStatus.Disconnected; lock (syncRoot) { if (this.connectionStatus != current) { this.connectionStatus = current; } } NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(this.NetworkChange_NetworkAvailabilityChanged); }
public static async void Connect(string serverIP, string serverPort) { try { Status = ConnectionStatus.Connecting; _hostName = new HostName(serverIP); _streamSocket = new StreamSocket(); await _streamSocket.ConnectAsync(_hostName, serverPort); Status = ConnectionStatus.Connected; _writer = new DataWriter(_streamSocket.OutputStream); } catch (Exception e) { Status = ConnectionStatus.Failed; //todo:log errors } }
public void Open() { Debug.Assert(Status == ConnectionStatus.Initialized, "Connection.Open: Status must be Initialized."); if (Status == ConnectionStatus.Initialized) { try { _oriConnection.Open(); Status = ConnectionStatus.Opend; } catch (Exception e) { #if DEBUG DbConnectException dce = new DbConnectException(e); Debug.WriteLine(dce); throw dce; #endif } } }
private static ConnectionInfo UpdateConnectionInfo(ConnectionInfo previousConnectionInfo, ConnectionStatus connectionStatus) { ConnectionInfo newConnectionInfo; if ((previousConnectionInfo.Status == ConnectionStatus.Disconnected || previousConnectionInfo.Status == ConnectionStatus.Connecting) && connectionStatus == ConnectionStatus.Connected) { newConnectionInfo = new ConnectionInfo(connectionStatus, previousConnectionInfo.ConnectCount + 1); } else { newConnectionInfo = new ConnectionInfo(connectionStatus, previousConnectionInfo.ConnectCount); } if (Log.IsEnabled(LogEventLevel.Information)) { Log.Information(newConnectionInfo.ToString()); } return newConnectionInfo; }
public ConnectionInfo(ConnectionStatus connectionStatus, string server, string transportName) { ConnectionStatus = connectionStatus; Server = server; TransportName = transportName; }
public static void ReceivedDeviceSdkCallback(IIdentity identity, ConnectionStatus status, ConnectionStatusChangeReason reason) { Log.LogDebug((int)EventIds.ReceivedCallback, $"Received connection status changed callback with connection status {status} and reason {reason} for {identity.Id}"); }
private void ConnectionStatusChangeHandler(ConnectionStatus status, ConnectionStatusChangeReason reason) { DisplayStatus(string.Format("Connection Status Changed to {0} change reason {1}", status, reason)); }
/// <summary> /// 前端连接回报 /// </summary> private void CTradeApi_OnFrontConnected() { this._connStatus = ConnectionStatus.Connected; this._OnConnectionStatusChanged?.Invoke(this._connStatus); }
public Steam() { Status = ConnectionStatus.Disconnected; _bot = null; }
/// <summary> /// Connection status message construtor. /// </summary> /// <param name="node">Sender node</param> /// <param name="endpoint">Endpoint for the connection status.</param> /// <param name="status">Node connection status.</param> public ConnectionStatusInfo(ConnectionStatus status, string endpoint, INyxNode node) { Node = node; Endpoint = endpoint; Status = status; }
public virtual void Connection() => ConnectionStatus = ConnectionStatus.Connected;
public void OnConnectionStatusChanged(ConnectionStatus connectionStatus) { }
public ConnectionStatusInfo(ConnectionStatus status, string endpoint) : this(status, endpoint, null) { }
void Transport_onStatus(ConnectionStatus status, ConnectionErrors error, string errorMsg) { this.connStatus = status; if (onStatus != null) { if (WebErrorStatus.ConnectionAborted.ToString().Equals(errorMsg)) { if (this.shouldConnect) onStatus(status, error, errorMsg + " " + ErrorMessage.reconnIn5s); else onStatus(status, error, errorMsg); ThreadPoolTimer timer = ThreadPoolTimer.CreateTimer( async (obj) => { await ThreadPool.RunAsync(TryToConnectDisconnect, WorkItemPriority.High); }, new TimeSpan(0, 0, 0, 0, 5000)); } else { onStatus(status, error, errorMsg); if (error == ConnectionErrors.AUTH_FAILED) { this.shouldConnect = false; } } } else throw new ArgumentNullException("Error: " + this.GetType() + " require a StatusEventHandler onStatus"); }
private static void ConnectionStatusChangeHandler(IDxConnection connection, ConnectionStatus oldStatus, ConnectionStatus newStatus) { switch (newStatus) { case ConnectionStatus.Connected: Console.WriteLine("Connected!"); break; case ConnectionStatus.Authorized: Console.WriteLine("Authorized!"); break; case ConnectionStatus.NotConnected: break; case ConnectionStatus.LoginRequired: break; default: throw new ArgumentOutOfRangeException(nameof(newStatus), newStatus, null); } }
internal void PopulateBusinessObjectFromReader(ConnectionStatus businessObject, IDataReader dataReader) { if (_dicIndex.Count == 0) { FillDicIndex(dataReader); } if (GetIndex(ConnectionStatus.ConnectionStatusFields.CreatedAt.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ConnectionStatus.ConnectionStatusFields.CreatedAt.ToString()))) { businessObject.CreatedAt = dataReader.GetDateTime(GetIndex(ConnectionStatus.ConnectionStatusFields.CreatedAt.ToString())); } } if (GetIndex(ConnectionStatus.ConnectionStatusFields.CreatedBy.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ConnectionStatus.ConnectionStatusFields.CreatedBy.ToString()))) { businessObject.CreatedBy = dataReader.GetInt32(GetIndex(ConnectionStatus.ConnectionStatusFields.CreatedBy.ToString())); } } if (GetIndex(ConnectionStatus.ConnectionStatusFields.Description.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ConnectionStatus.ConnectionStatusFields.Description.ToString()))) { businessObject.Description = dataReader.GetString(GetIndex(ConnectionStatus.ConnectionStatusFields.Description.ToString())); } } businessObject.Id = dataReader.GetInt32(GetIndex(ConnectionStatus.ConnectionStatusFields.Id.ToString())); if (GetIndex(ConnectionStatus.ConnectionStatusFields.IsDeleted.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ConnectionStatus.ConnectionStatusFields.IsDeleted.ToString()))) { businessObject.IsDeleted = dataReader.GetInt32(GetIndex(ConnectionStatus.ConnectionStatusFields.IsDeleted.ToString())); } } if (GetIndex(ConnectionStatus.ConnectionStatusFields.Name.ToString()) != -1) { businessObject.Name = dataReader.GetString(GetIndex(ConnectionStatus.ConnectionStatusFields.Name.ToString())); } if (GetIndex(ConnectionStatus.ConnectionStatusFields.UpdatedAt.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ConnectionStatus.ConnectionStatusFields.UpdatedAt.ToString()))) { businessObject.UpdatedAt = dataReader.GetDateTime(GetIndex(ConnectionStatus.ConnectionStatusFields.UpdatedAt.ToString())); } } if (GetIndex(ConnectionStatus.ConnectionStatusFields.UpdatedBy.ToString()) != -1) { if (!dataReader.IsDBNull(GetIndex(ConnectionStatus.ConnectionStatusFields.UpdatedBy.ToString()))) { businessObject.UpdatedBy = dataReader.GetInt32(GetIndex(ConnectionStatus.ConnectionStatusFields.UpdatedBy.ToString())); } } }
/// <summary> /// 前端断连回报 /// </summary> /// <param name="reason"></param> private void CTradeApi_OnFrontDisConnected(int reason) { this._connStatus = ConnectionStatus.Disconnected; this._OnConnectionStatusChanged?.Invoke(this._connStatus); }
private void MainForm_Load(object sender, EventArgs e) { connectionStatus = Utility.ConnectionStatus.None; }
// If the client reports Connected status, it is already in operational state. // If the client reports Disconnected_retrying status, it is trying to recover its connection. // If the client reports Disconnected status, you will need to dispose and recreate the client. // If the client reports Disabled status, you will need to dispose and recreate the client. private bool ShouldClientBeInitialized(ConnectionStatus connectionStatus) { return((connectionStatus == ConnectionStatus.Disconnected || connectionStatus == ConnectionStatus.Disabled) && _deviceConnectionStrings.Any()); }
internal static void UpdatingDeviceConnectionStatus(string deviceId, ConnectionStatus connectionStatus) { Log.LogDebug((int)EventIds.UpdatingDeviceConnectionStatus, Invariant($"Updating device {deviceId} connection status to {connectionStatus}")); }
/// <summary> /// Constructor for <see cref="StatusChangeArgs"/>. /// </summary> public StatusChangeArgs(ConnectionStatus status) { Status = status; }
async void OnConnectionStatusChanged(ConnectionStatus status, ConnectionStatusChangeReason reason) { try { UpstreamProtocol protocol = this.ModuleConnection.GetModuleClient().Map(x => x.UpstreamProtocol).GetOrElse(UpstreamProtocol.Amqp); Events.ConnectionStatusChanged(status, reason); // We want to notify the IoT Edge daemon in the following two cases - // 1. The device has been deprovisioned and might have been reprovisioned on another IoT hub. // 2. The IoT Hub that the device belongs to is no longer in existence and the device might have been // moved to a different IoT hub. // // When the Amqp or AmqpWs protocol is used, the SDK returns a connection status change reason of // Device_Disabled when a device is either disabled or deleted in IoT hub. // For the Mqtt and MqttWs protocol however, the SDK returns a Bad_Credential status as it's not // possible for IoT hub to distinguish between 'device does not exist', 'device is disabled' and // 'device exists but wrong credentials were supplied' cases. // // When an IoT hub is no longer in existence (i.e., it has been deleted), the SDK returns the // connection status change reason of Bad_Credential for all the Amqp and Mqtt protocols. if ((reason == ConnectionStatusChangeReason.Device_Disabled && (protocol == UpstreamProtocol.Amqp || protocol == UpstreamProtocol.AmqpWs)) || reason == ConnectionStatusChangeReason.Bad_Credential) { await this.deviceManager.ReprovisionDeviceAsync(); } if (this.pullOnReconnect && this.initTask.IsCompleted && status == ConnectionStatus.Connected) { var delayedTwinPull = true; using (await this.twinLock.LockAsync()) { var now = DateTime.Now; if (now - this.lastTwinPullOnConnect > this.twinPullOnConnectThrottleTime && !this.isDelayedTwinPullInProgress.Get()) { this.lastTwinPullOnConnect = now; await this.RefreshTwinAsync(); delayedTwinPull = false; } } if (delayedTwinPull) { if (this.isDelayedTwinPullInProgress.GetAndSet(true)) { Interlocked.Increment(ref this.pullRequestCounter); } else { _ = this.DelayedRefreshTwinAsync(); } } } } catch (Exception ex) when(!ex.IsFatal()) { Events.ConnectionStatusChangedHandlingError(ex); } }
private void ClearStatus(ConnectionStatus connectionStatus) => status &= ~connectionStatus;
private void ConnectionStatusChangeHandler(IntPtr connection, ConnectionStatus oldStatus, ConnectionStatus newStatus, IntPtr userData) { connectionStatusListener?.Invoke(this, oldStatus, newStatus); }
public static void SkipUpdatingEdgeHubIdentity(string id, ConnectionStatus connectionStatus) { Log.LogDebug((int)EventIds.SkipUpdatingEdgeHubIdentity, Invariant($"Skipped updating connection status change to {connectionStatus} for {id}")); }
private void SetStatus(ConnectionStatus connectionStatus) => status |= connectionStatus;
public static void ConnectionStatusChanged(ConnectionStatus status, ConnectionStatusChangeReason reason) { Log.LogDebug((int)EventIds.ConnectionStatusChanged, $"Connection status changed to {status} with reason {reason}"); }
private void ConnectionStatusChangeHandler(ConnectionStatus status, ConnectionStatusChangeReason reason) { _logger.LogDebug($"Connection status changed: status={status}, reason={reason}"); s_connectionStatus = status; switch (s_connectionStatus) { case ConnectionStatus.Connected: _logger.LogDebug("### The DeviceClient is CONNECTED; all operations will be carried out as normal."); s_wasEverConnected = true; break; case ConnectionStatus.Disconnected_Retrying: _logger.LogDebug("### The DeviceClient is retrying based on the retry policy. Do NOT close or open the DeviceClient instance"); break; case ConnectionStatus.Disabled: _logger.LogDebug("### The DeviceClient has been closed gracefully." + "\nIf you want to perform more operations on the device client, you should dispose (DisposeAsync()) and then open (OpenAsync()) the client."); break; case ConnectionStatus.Disconnected: switch (reason) { case ConnectionStatusChangeReason.Bad_Credential: // When getting this reason, the current connection string being used is not valid. // If we had a backup, we can try using that. string badCs = _deviceConnectionStrings[0]; _deviceConnectionStrings.RemoveAt(0); if (_deviceConnectionStrings.Any()) { // Not great to print out a connection string, but this is done for sample/demo purposes. _logger.LogWarning($"The current connection string {badCs} is invalid. Trying another."); InitializeClient(); break; } _logger.LogWarning("### The supplied credentials are invalid. Update the parameters and run again."); break; case ConnectionStatusChangeReason.Device_Disabled: _logger.LogWarning("### The device has been deleted or marked as disabled (on your hub instance)." + "\nFix the device status in Azure and then create a new device client instance."); break; case ConnectionStatusChangeReason.Retry_Expired: _logger.LogWarning("### The DeviceClient has been disconnected because the retry policy expired." + "\nIf you want to perform more operations on the device client, you should dispose (DisposeAsync()) and then open (OpenAsync()) the client."); InitializeClient(); break; case ConnectionStatusChangeReason.Communication_Error: _logger.LogWarning("### The DeviceClient has been disconnected due to a non-retry-able exception. Inspect the exception for details." + "\nIf you want to perform more operations on the device client, you should dispose (DisposeAsync()) and then open (OpenAsync()) the client."); InitializeClient(); break; default: _logger.LogError("### This combination of ConnectionStatus and ConnectionStatusChangeReason is not expected, contact the client library team with logs."); break; } break; default: _logger.LogError("### This combination of ConnectionStatus and ConnectionStatusChangeReason is not expected, contact the client library team with logs."); break; } }
public virtual void Disonnection() => ConnectionStatus = ConnectionStatus.Disconnected;
protected override void OnConnect_3(ref CThostFtdcRspUserLoginField pRspUserLogin, ConnectionStatus result) { IsConnected = false; if (result == ConnectionStatus.Confirmed) { IsConnected = true; } OnConnect_1(this, ref pRspUserLogin, result); }
/// <summary> /// Stops the Ident server. /// </summary> public void Stop() { this.Status = ConnectionStatus.Disconnected; if (this.listener != null) { this.listener.Stop(); } }
public ConnectionInfo( string protocol_name, ConnectionType type, ConnectionStatus status, string remote_name, IPEndPoint remote_endpoint, RemoteHostStatus remote_host_status, long? content_position, float? recv_rate, float? send_rate, int? local_relays, int? local_directs, string agent_name) { ProtocolName = protocol_name; Type = type; Status = status; RemoteName = remote_name; RemoteEndPoint = remote_endpoint; RemoteHostStatus = remote_host_status; ContentPosition = content_position; RecvRate = recv_rate; SendRate = send_rate; LocalRelays = local_relays; LocalDirects = local_directs; AgentName = agent_name; }
protected virtual void OnConnect_3(ref CThostFtdcRspUserLoginField pRspUserLogin, ConnectionStatus result) { OnConnect_1(this, ref pRspUserLogin, result); }
private void AzureSession_OnConnectionStatusChanged(ConnectionStatus status, Result result) { Debug.Log($"Connection status: '{status}', result: '{result}'"); isConnected = (status == ConnectionStatus.Connected); }
/// <summary> /// Starts the Ident server. /// </summary> /// <param name="stopAfterFirstAnswer">If true, Ident will stop immediately after answering. If false, will continue until <see cref="Stop"/> is called.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task Start(bool stopAfterFirstAnswer) { if (this.Status != ConnectionStatus.Disconnected) { Trace.WriteLine("Ident listener already started.", "Ident"); return; } this.Status = ConnectionStatus.Connecting; try { this.listener = new TcpListener(IPAddress.Any, 113); this.listener.Start(); while (this.Status != ConnectionStatus.Disconnected) { using (var client = await this.listener.AcceptTcpClientAsync()) { var stream = client.GetStream(); this.Status = ConnectionStatus.Connected; // Read query using (var reader = new StreamReader(stream)) { var ports = await reader.ReadLineAsync(); if (ports != null) { using (var writer = new StreamWriter(stream)) { // Send back reply var userId = "Supay"; if (this.User != null) { if (!string.IsNullOrEmpty(this.User.Username)) { userId = this.User.Username; } else if (!string.IsNullOrEmpty(this.User.Nickname)) { userId = this.User.Nickname; } } var response = ports + " : USERID : UNIX : " + userId; await writer.WriteLineAsync(response); await writer.FlushAsync(); } } } } if (stopAfterFirstAnswer) { this.Status = ConnectionStatus.Disconnected; } } } catch (Exception ex) { Trace.WriteLine("Unexpected error on Ident listener: " + ex, "Ident"); this.Status = ConnectionStatus.Disconnected; throw; } finally { this.listener.Stop(); } }
protected virtual void OnDisconnect_3(ref CThostFtdcRspInfoField pRspInfo, ConnectionStatus step) { IsConnected = false; OnDisconnect_1(this, ref pRspInfo, step); }
private void TryToConnectDisconnect(object state) { if (this.hasNetwork) { if (shouldConnect && connStatus != ConnectionStatus.CONNECTED && connStatus != ConnectionStatus.CONNECTING) { Transport.Connect(this.tOptions); } else if (!shouldConnect && connStatus != ConnectionStatus.DISCONNECTED && connStatus != ConnectionStatus.DISCONNECTING) { connStatus = ConnectionStatus.DISCONNECTING; Transport.Disconnect(); } } else this.onStatus(connStatus, ConnectionErrors.TECH_ERROR, ErrorMessage.noConnectivity); }
public void SetConnectionStatusTo(ConnectionStatus newConnectionStatus) { this.ConnectionStatus = newConnectionStatus; }
protected override void OnConnectionStatus(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1) { base.OnConnectionStatus(sender, status, ref userLogin, size1); if (status == ConnectionStatus.Logined) { TradingDay = userLogin.TradingDay; SaveAsTradingDay(); } }
private void OnStarted() { Status = ConnectionStatus.Started; DispatchOnMainThread(() => Started?.Invoke(this, EventArgs.Empty)); }