protected virtual void OnOffline(object sender, EventArgs args) { if (IsOnline) { Offline?.Invoke(sender, args); } Request = null; this.IsOnline = false; }
private void Session_StateChanged(object sender, AudioSessionStateChangedEventArgs e) { if (e.NewState == AudioSessionState.AudioSessionStateActive) { Online?.Invoke(this, new EventArgs()); } else { Offline?.Invoke(this, new EventArgs()); } }
public void Remove(T key, string connectionId) { lock (_connections) { if (_connections.TryGetValue(key, out HashSet <string> connections)) { connections.Remove(connectionId); if (connections.Count == 0) { _connections.Remove(key); Offline?.Invoke(this, key); } } } }
/// <summary> /// Opens this PortBridgeServerProxy instance and listens for new connections coming through Service Bus. /// </summary> /// <exception cref="System.Security.SecurityException">Throws a SecurityException if Group Policy prohibits Resource Publishing.</exception> public async Task Open() { if (this.IsOpen) { throw new InvalidOperationException(); } this.listener = new HybridConnectionListener(connectionString.ToString()); this.listener.Online += (s, e) => { Online?.Invoke(this, e); }; this.listener.Offline += (s, e) => { Offline?.Invoke(this, e); }; this.listener.Connecting += (s, e) => { Connecting?.Invoke(this, e); }; await listener.OpenAsync(shuttingDown.Token); this.IsOpen = true; AcceptLoopAsync().Fork(this); }
public static bool CheckForPi() { Finding?.Invoke(null, EventArgs.Empty); var found = PingHost(piIP.ToString(), Port); if (PiFound && !found) { Offline?.Invoke(null, EventArgs.Empty); } if (!PiFound && found) { Online?.Invoke(null, EventArgs.Empty); } PiFound = found; return(PiFound); }
private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e) { if (e.IsAvailable) { Login().Wait(); Online?.Invoke(this, new CDOEventArgs() { Session = this }); } else { LoginHttpStatus = HttpStatusCode.ServiceUnavailable; Offline?.Invoke(this, new CDOOfflineEventArgs() { Session = this }); } }
private void Session_SessionDisconnected(object sender, AudioSessionDisconnectedEventArgs e) => Offline?.Invoke(this, new EventArgs());
public static void OnOffline() { Offline.Invoke(); }