Handle an ClientHello message. Send available containers to the client
348916
async def handle_client_hello(self, client_addr, _: ClientHello):
        
        self._logger.info("New client connected %s", client_addr)
        self._registered_clients.add(client_addr)
        await self.send_container_update_to_client([client_addr])
957239
def _send(self, message):
        
        message['command'] = 'zappa.asynchronous.route_sns_task'
        payload = json.dumps(message).encode('utf-8')
        if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover
            raise AsyncException("Payload too large for SNS")
        self.response = self.client.publish(
                                TargetArn=self.arn,
                                Message=payload
                            )
        self.sent = self.response.get('MessageId')
479001
def _handle_one(self):
        
        ready_to_read, ready_to_write, in_error = select.select(
            [self.request], [self.request], [self.request], 0.1)

        if in_error:
            raise self.Disconnect()

        # Write any commands to the client
        while self.send_queue and ready_to_write:
            msg = self.send_queue.pop(0)
            self._send(msg)

        # See if the client has any commands for us.
        if ready_to_read:
            self._handle_incoming()
747493
def send_message(msg)
      ws.send(msg)
    rescue => exc
      warn exc
      abort exc
    end
802437
function Client(options) {
  var self = this;

  // Filers
  this.__filters_in__ = [];
  this.__filters_out__ = [];

  // Subscriptions
  this.__subscriptions__ = [];

  // Current node id
  this.__node_id__ = Math.floor(Math.random() * 1e10) + 1;

  // Message incremental counter
  this.__last_message_cnt__ = 0;

  // List of ignoring messages
  this.__ignore_list__ = {};

  // Router
  this.__router__ = options.router;

  this.__router__.onmessage(function (channel, message) {
    self.__onmessage__(channel, message);
  });

  // Lock handlers
  this.__lock_handlers__ = {};

  // If client make lock request - store handler and remove it from message
  this.filterOut(function (channel, message, callback) {
    if (channel === '!sys.lock.request') {
      var fn = message.data.fn;
      var lockId = message.data.id;

      delete message.data.fn;

      // Wrap handler to pass unlock function into it
      self.__lock_handlers__[message.id] = function () {
        fn(function unlock() {
          self.emit('!sys.lock.release', { id: lockId });
        });
      };
    }

    callback(channel, message);
  });

  // If lock acquired - execute handler
  this.filterIn(function (channel, message, callback) {
    if (channel === '!sys.lock.acquired' && self.__lock_handlers__[message.data.request_id]) {
      self.__lock_handlers__[message.data.request_id]();
      delete self.__lock_handlers__[message.data.request_id];
    }

    callback(channel, message);
  });
}
1172798
def _handle_message(self, data):
        
        if data.type == MSG_SERVER_SETTINGS:
            _LOGGER.info(data.payload)
        elif data.type == MSG_SAMPLE_FORMAT:
            _LOGGER.info(data.payload)
            self._connected = True
        elif data.type == MSG_TIME:
            if not self._buffered:
                _LOGGER.info('Buffering')
        elif data.type == MSG_HEADER:
            # Push to app source and start playing.
            _LOGGER.info(data.payload.codec.decode('ascii'))
            self._source.push(data.payload.header)
            self._source.play()
        elif data.type == MSG_WIRE_CHUNK:
            # Add chunks to play queue.
            self._buffer.put(data.payload.chunk)
            if self._buffer.qsize() > BUFFER_SIZE:
                self._buffered = True
            if self._buffer.empty():
                self._buffered = False
437480
function sendMessage(client, to, message, callback) {
	resolveID(client, to, function(channelID) {
		client._req('post', Endpoints.MESSAGES(channelID), message, function(err, res) {
			handleResCB("Unable to send messages", err, res, callback);
		});
	});
}
765847
def send_msg_to_clients(client_ids, msg, error=False):
    """"""
    if error:
        stream = "stderr"
    else:
        stream = "stdout"

    response = [{"message": None, "type": "console", "payload": msg, "stream": stream}]

    for client_id in client_ids:
        logger.info("emiting message to websocket client id " + client_id)
        socketio.emit(
            "gdb_response", response, namespace="/gdb_listener", room=client_id
        )
678110
def handle(self, message):
        '''
        
        '''

        logger.debug(message)
        if Utilities.isNotEmpty(message['metadata']['opts']):
            target = message['metadata']['opts']['target']

            for split_line in Utilities.tokenize(message['text']):
                for truncated_line in Utilities.truncate(split_line):
                    self.botThread.connection.privmsg(target, truncated_line)
                    # Delay to prevent floods
                    time.sleep(0.25)
568435
def on_message(self, client_conn, msg):
        
        MAX_QUEUE_SIZE = 30
        if len(self._msg_queue) >= MAX_QUEUE_SIZE:
            # This should never happen if callers to handle_message wait
            # for its futures to resolve before sending another message.
            # NM 2014-10-06: Except when there are multiple clients. Oops.
            raise RuntimeError('MessageHandlerThread unhandled '
                               'message queue full, not handling message')
        ready_future = Future()
        self._msg_queue.append((ready_future, client_conn, msg))
        self._wake.set()
        return ready_future
1181517
def on_message(self, message):
        
        message = ObjectDict(escape.json_decode(message))
        if message.command == 'hello':
            handshake = {
                'command': 'hello',
                'protocols': [
                    'http://livereload.com/protocols/official-7',
                ],
                'serverName': 'livereload-tornado',
            }
            self.send_message(handshake)

        if message.command == 'info' and 'url' in message:
            logger.info('Browser Connected: %s' % message.url)
            LiveReloadHandler.waiters.add(self)
131567
def handleRequest(self, obj, socket, multi=False):
        '''
        
        '''
        while 1:
            try:
                msg = socket.recv_multipart(zmq.NOBLOCK)
                method = msg[0].decode()
                try:
                    args = pickle.loads(msg[1], **pickle_options)
                except ValueError as err:
                    self._logger.notice('Request %s failed. Caught %s %s' %
                                        (method, type(err), str(err)))
                    self._sendAnswer(socket, err)
                self._logger.debug("received request %s %s" %
                                   (method, str(args)))
                try:
                    res= getattr(obj, method).__call__(*args)
                except Exception as e:
                    self._logger.notice('Request %s %s failed. Caught %s %s' %
                                        (method, str(args), type(e), str(e)))
                    res= e
                self._sendAnswer(socket, res)
            except zmq.ZMQError:
                return
            except Exception as e:
                self._logger.error("Unknown error %s" % str(e))
            if not multi:
                break
853330
function sendSocketMessage(message) {
    clients.forEach(function (client) {
      if (client.readyState === WebSocket.OPEN) {
        client.send(message || 'refresh', function (err) {
          if (err) {
            npmlog.error(err);
          }
        });
      }
    });
  }
707739
def _client_wrapper(attr, *args, **kwargs):
    '''
    
    '''
    catch_api_errors = kwargs.pop('catch_api_errors', True)
    func = getattr(__context__['docker.client'], attr, None)
    if func is None or not hasattr(func, '__call__'):
        raise SaltInvocationError('Invalid client action \'{0}\''.format(attr))
    if attr in ('push', 'pull'):
        try:
            # Refresh auth config from config.json
            __context__['docker.client'].reload_config()
        except AttributeError:
            pass
    err = ''
    try:
        log.debug(
            'Attempting to run docker-py\'s "%s" function '
            'with args=%s and kwargs=%s', attr, args, kwargs
        )
        ret = func(*args, **kwargs)
    except docker.errors.APIError as exc:
        if catch_api_errors:
            # Generic handling of Docker API errors
            raise CommandExecutionError(
                'Error {0}: {1}'.format(exc.response.status_code,
                                        exc.explanation)
            )
        else:
            # Allow API errors to be caught further up the stack
            raise
    except docker.errors.DockerException as exc:
        # More general docker exception (catches InvalidVersion, etc.)
        raise CommandExecutionError(exc.__str__())
    except Exception as exc:
        err = exc.__str__()
    else:
        return ret

    # If we're here, it's because an exception was caught earlier, and the
    # API command failed.
    msg = 'Unable to perform {0}'.format(attr)
    if err:
        msg += ': {0}'.format(err)
    raise CommandExecutionError(msg)
889865
def _SendOp(self):
    """"""
    msg = self._sender_queue.get()
    msgs = []
    background_msgs = []
    if not msg.require_fastpoll:
      background_msgs.append(msg)
    else:
      msgs.append(msg)

    count = 1
    size = len(msg.SerializeToString())

    while count < 100 and size < 1024 * 1024:
      try:
        msg = self._sender_queue.get(timeout=1)
        if not msg.require_fastpoll:
          background_msgs.append(msg)
        else:
          msgs.append(msg)
        count += 1
        size += len(msg.SerializeToString())
      except queue.Empty:
        break

    if msgs:
      self._SendMessages(msgs)
    if background_msgs:
      self._SendMessages(background_msgs, background=True)
1247485
async def _handle_container(self, message):
        
        self._log.debug('Handling container')
        for inner_message in message.obj.messages:
            await self._process_message(inner_message)
859560
def _message(status, content):
    
    event = f'message.{status}'
    if flask.has_request_context():
        emit(event, dict(data=pack(content)))
    else:
        sio = flask.current_app.extensions['socketio']
        sio.emit(event, dict(data=pack(content)))
    eventlet.sleep()