Periodic callback that checks for devices that haven't been used and disconnects them.
326945
def _disconnect_hanging_devices(self):
        """"""

        now = monotonic()
        for uuid, data in self._connections.items():
            if (now - data['last_touch']) > self.client_timeout:
                self._logger.info("Disconnect inactive client %s from device 0x%X", data['client'], uuid)
                self._loop.add_callback(self._disconnect_from_device, uuid, data['key'], data['client'], unsolicited=True)
388348
function(callback) {
        if (this._isShuttingDown || this._isStartingUp) {
            return;
        }

        this._isShuttingDown = true;

        // See if the app is running.
        if (!this.processId() && !this.sideProcessId()) {
            this._isShuttingDown = false;
            // Nope, not running.
            if (callback) {
                callback();
            }

            return;
        }

        // Kill the app.
        clearTimeout(this._restartTimeout);
        this._appProcess.kill();
        if (this._sideProcess) {
            this._sideProcess.kill();
        }

        // Check on an interval to see if it's dead.
        var check = setInterval(_.bind(function() {
            if (this.processId() || this.sideProcessId()) {
                return;
            }

            clearInterval(check);
            logger.info('App shut down by force.');
            this._isShuttingDown = false;
            if (callback) {
                callback();
            }
        }, this), 250);
    }
985736
function (callback) {
            debug('');

            self.sagaStore.on('connect', function () {
              self.emit('connect');
            });

            self.sagaStore.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.sagaStore.connect(callback);
          }
1090776
@Override
    protected void checkIfAlreadyConnected(DeviceProxy device, String attribute, String event_name, CallBack callback, int max_size, boolean stateless) throws DevFailed {
        //  Nothing to do (only override)
    }
1343397
def _treat_devices_removed(self):
        """"""
        for device in self._removed_ports.copy():
            eventlet.spawn_n(self._process_removed_port, device)
1358277
function (callback) {
            debug('');

            self.eventStore.on('connect', function () {
              self.emit('connect');
            });

            self.eventStore.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.eventStore.init(callback);
          }
391232
def _notify_disconnected(self):
        ''' 

        '''
        if self.document is not None:
            self.document.remove_on_change(self)
            self._callbacks.remove_all_callbacks()
1371190
def _tcpdump_callback(self, line, kill_switch):
    """"""

    line = line.lower()
    if ("listening" in line) or ("reading" in line):
        self.started = True
    if ("no suitable device" in line):
        self.error = True
        self.kill_switch()
    if "by kernel" in line:
        self.stopped = True
701686
def _notify_trace(self, device_uuid, event_name, trace):
        

        if device_uuid not in self._connections:
            self._logger.debug("Dropping trace data for device without an active connection, uuid=0x%X", device_uuid)
            return

        conn_data = self._connections[device_uuid]
        last_trace = conn_data['last_trace']
        now = monotonic()

        conn_data['trace_accum'] += bytes(trace)

        # If we're throttling tracing data, we need to see if we should accumulate this trace or
        # send it now.  We acculumate if we've last sent tracing data less than self.throttle_trace seconds ago
        if last_trace is not None and (now - last_trace) < self.throttle_trace:
            if not conn_data['trace_scheduled']:
                self._loop.call_later(self.throttle_trace - (now - last_trace), self._send_accum_trace, device_uuid)
                conn_data['trace_scheduled'] = True
                self._logger.debug("Deferring trace data due to throttling uuid=0x%X", device_uuid)
        else:
            self._send_accum_trace(device_uuid)
419549
function (successCallback, errorCallback, deviceId) {

			// Find the requested device in our list of discovered devices
			var device = winble.deviceManager.getDeviceFromId(deviceId, "connectToDevice", errorCallback);
			if (device == null) {
				errorCallback(winble.DEVICE_NOT_FOUND);
				return;
			}

			// Save the success callback; we will need to call this whenever the connection status changes.
			if (device.connectSuccessCallback == null)
				device.connectSuccessCallback = successCallback;

			// Call the success callback if the device is connected, error callback if not
			if (device.isReachable && device.isConnected) {
				winble.logger.logDebug("connectToDevice", "Connection successful");
				var connectInfo = {
					"deviceHandle": device.handle,
					"state": 2 // 0 = Disconnected, 1 = Connecting, 2 = Connected, 3 = Disconnecting
				};
				device.connectSuccessCallback(connectInfo, { keepCallback: true });
			} else {
				winble.logger.logDebug("connectToDevice", "Connection failed");
				errorCallback(winble.DEVICE_NOT_CONNECTED);
			}
		}
303869
function(params, callback) {
      var t = this,
          disconnectError = false;

      if (!t.get('started')) {
        var err = {code:'NOT_RUNNING', msg:'The recipe is already stopped.'};
        logger.warn('precondition', err);
        return callback(err);
      }

      // Called when a monitor has disconnected
      var onDisconnect = function(error) {
        if (disconnectError) {return;}
        if (error) {
          var err = {code:'DISONNECT_ERROR', err: error};
          disconnectError = true;
          logger.error('onDisconnect', err);
          return callback(err);
        }
        for (var name1 in t.monitors) {
          if (t.monitors[name1].isConnected()) {
            return;
          }
        }
        t.set({started:false});
        t.compiledScript = null;
        callback();
      };

      // Disconnect all monitors
      t.connectListeners(false);
      t.context = null;
      for (var name2 in t.monitors) {
        t.monitors[name2].disconnect(onDisconnect);
      }
    }
632271
def async_new_device_callback(self, device):
        """"""
        _LOGGING.info(
            'New Device: %s cat: 0x%02x subcat: 0x%02x desc: %s, model: %s',
            device.id, device.cat, device.subcat,
            device.description, device.model)
        for state in device.states:
            device.states[state].register_updates(
                self.async_state_change_callback)
596800
def restart_inactivity_timer
      @inactivity_timer.cancel if @inactivity_timer
      @inactivity_timer = EM::Timer.new(@check_interval) do
        begin
          check(id = nil, max_ping_timeouts = 1)
        rescue Exception => e
          ErrorTracker.log(self, "Failed connectivity check", e)
        end
      end
      true
    end
892523
def disconnect(self, func):
        """"""
        if id(self) not in _alleged_receivers:
            return
        l = _alleged_receivers[id(self)]
        try:
            l.remove(func)
        except ValueError:
            return
        if not l:
            del _alleged_receivers[id(self)]
831461
def _on_scan(_loop, adapter, _adapter_id, info, expiration_time):
    """"""

    info['validity_period'] = expiration_time
    adapter.notify_event_nowait(info.get('connection_string'), 'device_seen', info)
288671
def _disconnect_locked(self):
    """"""
    self._connected = False
    self._connect_cond.notify_all()
    self._telnet = None
    _LOGGER.warning("Disconnected")
802564
function closeConn(userId) {
            if(recorder && recorderTimeoutID) {
                recorder.stop();
            }

            app.helpers.notifyIfUserLeaveCall(app.currentSession, userId, 'disconnected', 'Disconnected');
            app.currentSession.closeConnection(userId);
        }