Invoke the callback with a command-object for each connection.
321408
def command_for_all_connections(self, cb):
        """"""

        for connection in self.__master.connections:
            cb(connection.command)
761114
public function executeCommand(CommandInterface $command, callable $callback)
    {
        $this->connection->executeCommand($command, $this->wrapCallback($callback));
    }
1269975
def trigger(self, *args, **kwargs):
        """"""
        for h in self.handlers:
            h(*args, **kwargs)
867568
def call(self, name: str, *args, **kwargs):
        ''''''
        if self._event_dispatcher is not None:
            self._event_dispatcher.notify(name, *args, **kwargs)

        if self._callbacks[name]:
            return self._callbacks[name](*args, **kwargs)
        else:
            raise HookDisconnected('No callback is connected.')
1330042
function CommandProcessor(conn) {
	events.EventEmitter.call(this);

	this.conn = conn;

	this.connected_at = +new Date();
	this.last_data_at = 0;
	this.last_ping_at = 0;

	p.data_timeout = -1; // disabled
	p.data_timeout_TID = null;

	p.ping_timeout = -1; // disabled
	p.ping_timeout_TID = null;

	this._request_id = 0;
	this._requests_in_flight = {};

	this.last_line   = '';

	// handling disconnection can only be done once
	var _handle_disconnection = _.once(this._handle_disconnection.bind(this));

	conn.on('data',  this.process_data.bind(this));
	conn.on('error', _handle_disconnection);
	conn.on('end',   _handle_disconnection); // Do we really need this?
	conn.on('close', _handle_disconnection);

	// bind some methods to current instance for easy reuse
	this._emit_data_timeout = this._emit_data_timeout .bind(this);
	this._emit_ping_timeout = this._emit_ping_timeout .bind(this);
	this.set_timeouts();
}
551272
def call(command, params)
      @command = command
      request = Net::HTTP::Get.new(uri.request_uri + "?" + params)
      response = http.request(request)
      Response.new(response.body, response)
    end
1290843
def _call_callbacks(self):
        """"""
        for callback in self._callbacks:
            callback(self, self._changeset)
        self._changeset = {}
121085
def _call_command(self, name, *args, **kwargs):
        
        obj = getattr(self, '_instance', self)  # _instance if a field, self if an instance

        # The object may not be already connected, so if we want to update a
        # field, connect it before.
        # If the object as no PK yet, let the object create itself
        if name in self.available_modifiers and obj._pk and not obj.connected:
            obj.connect()

        # Give priority to a "_call_{commmand}" method
        meth = getattr(self, '_call_%s' % name, self._traverse_command)
        return meth(name, *args, **kwargs)
59305
def send_command(self, obj, command, *arguments):
        
        self._perform_command('{}/{}'.format(self.session_url, obj.ref), command, OperReturnType.no_output, *arguments)
51770
def __callbacks(self, msg):
            ''''''
            if self.callback:
                self.callback(msg, *self.callback_args, **self.callback_kwargs)
19450
def execute(self, raise_on_error=True):
        ""
        stack = self.command_stack
        if not stack:
            return []
        execute = self._execute_pipeline

        conn = self.connection
        if not conn:
            conn = self.connection_pool.get_connection('batch')
            # assign to self.connection so reset() releases the connection
            # back to the pool after we're done
            self.connection = conn

        try:
            return execute(conn, stack, raise_on_error)
        except ConnectionError:
            conn.disconnect()
            return execute(conn, stack, raise_on_error)
        finally:
            self.reset()
80388
function sendCommand(command, data, options, callback) {
  return this.sendJson({ command: command, data: data }, options, callback);
}
756234
async def execute_command(self, *args, **kwargs):
        
        # NOTE: don't parse the response in this function -- it could pull a
        # legitimate message off the stack if the connection is already
        # subscribed to one or more channels
        await self.connection_pool.initialize()

        if self.connection is None:
            self.connection = self.connection_pool.get_connection(
                'pubsub',
                channel=args[1],
            )
            # register a callback that re-subscribes to any channels we
            # were listening to when we were disconnected
            self.connection.register_connect_callback(self.on_connect)
        connection = self.connection
        await self._execute(connection, connection.send_command, *args)
191810
def invoke(self, method, relpath=None, params=None, data=None, headers=None):
    
    path = self._join_uri(relpath)
    resp = self._client.execute(method,
                                path,
                                params=params,
                                data=data,
                                headers=headers)
    try:
      body = resp.read()
    except Exception, ex:
      raise Exception("Command '%s %s' failed: %s" %
                      (method, path, ex))

    self._client.logger.debug(
        "%s Got response: %s%s" %
        (method, body[:32], len(body) > 32 and "..." or ""))

    # Is the response application/json?
    if len(body) != 0 and \
          resp.info().getmaintype() == "application" and \
          resp.info().getsubtype() == "json":
      try:
        json_dict = json.loads(body)
        return json_dict
      except Exception, ex:
        self._client.logger.exception('JSON decode error: %s' % (body,))
        raise ex
    else:
      return body
1297218
def do_callbacks(callback_type, object, options = {})
      return if $bot[:callbacks][callback_type].nil?
      $bot[:callbacks][callback_type].each do |c|
        c[:block].call object, options
      end
    end
21027
def write_command(self, command: Command):
        '''
        '''
        _logger.debug('Write command.')
        data = command.to_bytes()
        yield from self._connection.write(data)
        self._data_event_dispatcher.notify_write(data)
1277865
function _send(cmd, callback) {
      cmd_callback = callback;
      if(connected) {
        client.write(cmd + '\n');
      } else {
        connect();
      }
    }