Handle incoming CONNACK command.
483724
def handle_connack(self):
        """"""
        self.logger.info("CONNACK reveived")
        ret, flags = self.in_packet.read_byte()
        if ret != NC.ERR_SUCCESS:
            self.logger.error("error read byte")
            return ret
        
        # useful for v3.1.1 only
        session_present = flags & 0x01

        ret, retcode = self.in_packet.read_byte()
        if ret != NC.ERR_SUCCESS:
            return ret
        
        evt = event.EventConnack(retcode, session_present)
        self.push_event(evt)
        
        if retcode == NC.CONNECT_ACCEPTED:
            self.state = NC.CS_CONNECTED
            return NC.ERR_SUCCESS
        
        elif retcode >= 1 and retcode <= 5:
            return NC.ERR_CONN_REFUSED
        else:
            return NC.ERR_PROTOCOL
114280
async def immediate_execute_command(self, *args, **options):
        
        command_name = args[0]
        conn = self.connection
        # if this is the first call, we need a connection
        if not conn:
            conn = self.connection_pool.get_connection()
            self.connection = conn
        try:
            await conn.send_command(*args)
            return await self.parse_response(conn, command_name, **options)
        except (ConnectionError, TimeoutError) as e:
            conn.disconnect()
            if not conn.retry_on_timeout and isinstance(e, TimeoutError):
                raise
            # if we're not already watching, we can safely retry the command
            try:
                if not self.watching:
                    await conn.send_command(*args)
                    return await self.parse_response(conn, command_name, **options)
            except ConnectionError:
                # the retry failed so cleanup.
                conn.disconnect()
                await self.reset()
                raise
218182
def handle_event(self, packet):
        """"""
        if packet.get('command'):
            task = self.send_command_ack(packet['id'], packet['command'])
            self.loop.create_task(task)
1302381
private void handleMasterCommand(Command cmd) throws IOException, ConnectionFailedException {
    if (cmd == null) {
      return;
    }
    switch (cmd.getCommandType()) {
      // Currently unused
      case Delete:
        break;
      // Master requests blocks to be removed from Alluxio managed space.
      case Free:
        mAsyncBlockRemover.addBlocksToDelete(cmd.getDataList());
        break;
      // No action required
      case Nothing:
        break;
      // Master requests re-registration
      case Register:
        mWorkerId.set(mMasterClient.getId(mWorkerAddress));
        registerWithMaster();
        break;
      // Unknown request
      case Unknown:
        LOG.error("Master heartbeat sends unknown command {}", cmd);
        break;
      default:
        throw new RuntimeException("Un-recognized command from master " + cmd);
    }
  }
587635
def handle(self):
        ""
        if self.TELNET_ISSUE:
            self.writeline(self.TELNET_ISSUE)
        if not self.authentication_ok():
            return
        if self.DOECHO:
            self.writeline(self.WELCOME)

        self.session_start()
        while self.RUNSHELL:
            raw_input = self.readline(prompt=self.PROMPT).strip()
            self.input = self.input_reader(self, raw_input)
            self.raw_input = self.input.raw
            if self.input.cmd:
                cmd = self.input.cmd.upper()
                params = self.input.params
                if self.COMMANDS.has_key(cmd):
                    try:
                        self.COMMANDS[cmd](params)
                    except:
                        log.exception('Error calling %s.' % cmd)
                        (t, p, tb) = sys.exc_info()
                        if self.handleException(t, p, tb):
                            break
                else:
                    self.writeerror("Unknown command '%s'" % cmd)
        log.debug("Exiting handler")
1015489
def _handle_incoming_data(self, conn):
        
        connection = [c for c in self.connections if c.conn == conn][0]
        data = conn.recv(1024)
        if data:
            connection.feed(data)
        else:
            self.connections.remove(connection)
681244
def handle_command(command)
      case command
      when 'REHASH'  then @core.config.load!
      when 'STOP'    then Thread.new { @core.stop }
      else STDERR.puts "Unknown IPC command: #{command.inspect}"
      end
    end
645325
function handleControlConnection(connection) {
		connection.on('data', function (data) {
			console.log('Got command:', data.toString().trim());
			var request = data.toString().trim().split(' '),
				cmd = request[0],
				target = request[1],
				newline = '\r\n',
				response;
			console.log('Command is:', cmd);
			switch (cmd) {
				case 'start':
					console.log('got here');
					self.store.broadcast('worker:start', target);
					response = lib.format('Starting {0} servers.', (target || 'all'));
					break;
				case 'pause':
					self.store.broadcast('worker:pause', target);
					response = lib.format('Pausing {0} servers.', (target || 'all'));
					break;
				case 'stop':
					self.store.broadcast('worker:stop', target);
					response = lib.format('Stopping {0} servers.', (target || 'all'));
					break;
				case 'resume':
					self.store.broadcast('worker:resume', target);
					response = lib.format('Resuming {0} servers.', (target || 'all'));
					break;
				case 'heartbeat':
					var id = lib.guid();
					self.store.broadcast('worker:heartbeat', id);
					wait(id, function () {
						var args = Array.prototype.slice.call(arguments),
							response = {};
						lib.each(args, function (data) {
							var message = data[0],
								worker = data[1];
							response[worker] = message;
						});
						connection.write(JSON.stringify(response));
						connection.end(newline);
					});
					break;
				case 'stats':
					var id = lib.guid();
					self.store.broadcast('worker:stats', id);
					wait(id, function () {
						var args = Array.prototype.slice.call(arguments),
							response = {};
						lib.each(args, function (data) {
							var message = data[0],
								worker = data[1];
							response[worker] = message;
						});
						connection.write(JSON.stringify(response));
						connection.end(newline);
					});
					break;
				default:
					response = lib.format('Unknown command: {0}.', cmd);
					break;
			}
			if (response) {
				connection.write(response);
				connection.end(newline);
			}
		});
	}
319862
def _handle_command_buffer(self):
        """"""
        if self._should_write_to_command_buffer:
            self._write_to_command_buffer(self._commands.to_json())
            self._should_write_to_command_buffer = False
            self._commands.clear()
38962
def handle(conn, addr, gateway, *args, **kwargs):
    
    conn.sendall(b'OK pubsub 1.0\n')
    while True:
        try:
            s = conn.recv(1024).decode('utf-8').strip()
            if not s:
                conn.close()
                break
        except ConnectionResetError:
            logger.debug('Client close the connection.')
            break

        parts = s.split(' ')
        if len(parts) != 2:
            conn.send(b"Invalid command\n")
            continue
        cmd, topic = parts
        if cmd.lower() != 'sub':
            conn.send(bytes("Unknown command '{}'\n".format(cmd.lower()), 'utf-8'))
            continue
        if topic not in gateway.topics:
            conn.send(bytes("Unknown topic '{}'\n".format(topic), 'utf-8'))
            continue
        conn.sendall(bytes('ACK {} {}\n'.format(cmd, topic), 'utf-8'))
        subscriber = Subscriber(addr, conn)
        gateway.link(topic, subscriber)
        break
560781
def handle(self, *args, **options):
        """"""
        self.verbosity = int(options.get('verbosity'))
        self.quiet = options.get('quiet')
        self._set_logger_level()

        try:
            connection.close()
            self.filename = options.get('input_filename')
            self.path = options.get('input_path')
            self.servername = options.get('servername')
            self.decrypt = options.get('decrypt')
            self.uncompress = options.get('uncompress')
            self.passphrase = options.get('passphrase')
            self.interactive = options.get('interactive')
            self.database_name, self.database = self._get_database(options)
            self.storage = get_storage()
            self._restore_backup()
        except StorageError as err:
            raise CommandError(err)
249881
def handle(self, msg):
        """"""
        debug_msg = ': {!r}'.format(msg) if self.debug else ''
        log.debug('request: %d bytes%s', len(msg), debug_msg)
        buf = io.BytesIO(msg)
        code, = util.recv(buf, '>B')
        if code not in self.methods:
            log.warning('Unsupported command: %s (%d)', msg_name(code), code)
            return failure()

        method = self.methods[code]
        log.debug('calling %s()', method.__name__)
        reply = method(buf=buf)
        debug_reply = ': {!r}'.format(reply) if self.debug else ''
        log.debug('reply: %d bytes%s', len(reply), debug_reply)
        return reply
134048
def handle(self, pkt, raddress, rport):
        ""
        if isinstance(pkt, TftpPacketACK):
            log.debug("Received ACK for packet %d" % pkt.blocknumber)
            # Is this an ack to the one we just sent?
            if self.context.next_block == pkt.blocknumber:
                if self.context.pending_complete:
                    log.info("Received ACK to final DAT, we're done.")
                    return None
                else:
                    log.debug("Good ACK, sending next DAT")
                    self.context.next_block += 1
                    log.debug("Incremented next_block to %d",
                        self.context.next_block)
                    self.context.pending_complete = self.sendDAT()

            elif pkt.blocknumber < self.context.next_block:
                log.warning("Received duplicate ACK for block %d"
                    % pkt.blocknumber)
                self.context.metrics.add_dup(pkt)

            else:
                log.warning("Oooh, time warp. Received ACK to packet we "
                         "didn't send yet. Discarding.")
                self.context.metrics.errors += 1
            return self
        elif isinstance(pkt, TftpPacketERR):
            log.error("Received ERR packet from peer: %s" % str(pkt))
            raise TftpException("Received ERR packet from peer: %s" % str(pkt))
        else:
            log.warning("Discarding unsupported packet: %s" % str(pkt))
            return self
425766
def handle_line(self, line):
        """"""
        if not self.gateway.can_log:
            _LOGGER.debug('Receiving %s', line)
        self.gateway.add_job(self.gateway.logic, line)
158644
private void handleCommand(MetaCommand cmd) throws IOException {
    if (cmd == null) {
      return;
    }
    switch (cmd) {
      case MetaCommand_Nothing:
        break;
      // Leader master requests re-registration
      case MetaCommand_Register:
        setIdAndRegister();
        break;
      // Unknown request
      case MetaCommand_Unknown:
        LOG.error("Master heartbeat sends unknown command {}", cmd);
        break;
      default:
        throw new RuntimeException("Un-recognized command from leader master " + cmd);
    }
  }
333958
def _handler(self, conn):
        
        incoming = self.recv(conn)
        self.log(DEBUG, incoming)
        try:
            # E.g. ['twister', [7, 'invert'], {'guess_type': True}]
            task, args, kw = self.codec.decode(incoming)
            
            # OK, so we've received the information. Now to use it.
            self.log(INFO, 'Fulfilling task %r' % task)
            self.started_task()
            
            pass_backend = False
            obj = self.tasks[task]
            if _is_iter(obj):
                # (callable, bool)
                obj, pass_backend = obj
            if pass_backend:
                # Have to do this, since args is a list
                args = [self] + args
            
            # Get and package the result
            res = ['success', obj(*args, **kw)]
        except Exception as e:
            self.log(ERROR, 'Error while fullfilling task %r: %r' % (task, e))
            res = ['error', e.__class__.__name__, e.args]
            if self.tracebacks:
                show_err()
        else:
            self.log(INFO, 'Finished fulfilling task %r' % task)
        finally:
            self.send(conn, self.codec.encode(res))
            self.finished_task()
            conn.close()
338690
def handle(self):
        ""
        if not self.authentication_ok():
            return
        if self.DOECHO:
            self.writeline(self.WELCOME)
        self.session_start()
        while self.RUNSHELL:
            read_line = self.readline(prompt=self.PROMPT).strip('\r\n')
            if read_line:
                self.session.transcript_incoming(read_line)
            self.input = self.input_reader(self, read_line)
            self.raw_input = self.input.raw
            if self.input.cmd:
                # TODO: Command should not be converted to upper
                # looks funny in error messages.
                cmd = self.input.cmd.upper()
                params = self.input.params
                if cmd in self.COMMANDS:
                    try:
                        self.COMMANDS[cmd](params)
                    except:
                        logger.exception('Error calling {0}.'.format(cmd))
                        (t, p, tb) = sys.exc_info()
                        if self.handleException(t, p, tb):
                            break
                else:
                    self.writeline('-bash: {0}: command not found'.format(cmd))
                    logger.error("Unknown command '{0}'".format(cmd))
        logger.debug("Exiting handler")