Ejemplo n.º 1
0
 protected virtual void OnOffline(object sender, EventArgs args)
 {
     if (IsOnline)
     {
         Offline?.Invoke(sender, args);
     }
     Request       = null;
     this.IsOnline = false;
 }
Ejemplo n.º 2
0
 private void Session_StateChanged(object sender, AudioSessionStateChangedEventArgs e)
 {
     if (e.NewState == AudioSessionState.AudioSessionStateActive)
     {
         Online?.Invoke(this, new EventArgs());
     }
     else
     {
         Offline?.Invoke(this, new EventArgs());
     }
 }
Ejemplo n.º 3
0
 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);
             }
         }
     }
 }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 6
0
 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
         });
     }
 }
Ejemplo n.º 7
0
 private void Session_SessionDisconnected(object sender, AudioSessionDisconnectedEventArgs e) => Offline?.Invoke(this, new EventArgs());
Ejemplo n.º 8
0
 public static void OnOffline()
 {
     Offline.Invoke();
 }