Create a message event.
338649
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public MessageEvent createMessageEvent(Data data) {
    return MessageEvent.builder(MessageEvent.Type.SENT, MESSAGE_ID).build();
  }
156421
def add_message_event(proto_message, span, message_event_type, message_id=1):
    
    span.add_time_event(
        time_event=time_event.TimeEvent(
            datetime.utcnow(),
            message_event=time_event.MessageEvent(
                message_id,
                type=message_event_type,
                uncompressed_size_bytes=proto_message.ByteSize()
            )
        )
    )
1048726
def vip_create_event(self, vip_info):
        """"""
        vip_data = vip_info.get('vip')
        port_id = vip_data.get('port_id')
        vip_id = vip_data.get('id')
        self.add_lbaas_port(port_id, vip_id)
1270070
def add_message(self, text, type=None):
        """"""
        key = self._msg_key
        self.setdefault(key, [])
        self[key].append(message(type, text))
        self.save()
877086
async def on_message(self, event):
        
        # We want to show only messages sent to this chat
        if event.chat_id != self.chat_id:
            return

        # Save the message ID so we know which to reply to
        self.message_ids.append(event.id)

        # Decide a prefix (">> " for our messages, "<user>" otherwise)
        if event.out:
            text = '>> '
        else:
            sender = await event.get_sender()
            text = '<{}> '.format(sanitize_str(
                utils.get_display_name(sender)))

        # If the message has media show "(MediaType) "
        if event.media:
            text += '({}) '.format(event.media.__class__.__name__)

        text += sanitize_str(event.text)
        text += '\n'

        # Append the text to the end with a newline, and scroll to the end
        self.log.insert(tkinter.END, text)
        self.log.yview(tkinter.END)
425081
def create_event(self, state, server, agentConfig):
        """"""

        def get_state_description(state):
            if state == 0:
                return 'Starting Up'
            elif state == 1:
                return 'Primary'
            elif state == 2:
                return 'Secondary'
            elif state == 3:
                return 'Recovering'
            elif state == 4:
                return 'Fatal'
            elif state == 5:
                return 'Starting up (initial sync)'
            elif state == 6:
                return 'Unknown'
            elif state == 7:
                return 'Arbiter'
            elif state == 8:
                return 'Down'
            elif state == 9:
                return 'Rollback'

        status = get_state_description(state)
        msg_title = "%s is %s" % (server, status)
        msg = "TokuMX %s just reported as %s" % (server, status)

        self.event(
            {
                'timestamp': int(time.time()),
                'event_type': 'tokumx',
                'msg_title': msg_title,
                'msg_text': msg,
                'host': self.hostname,
            }
        )
257259
def handle_new_events(self, events):
        """"""
        for event in events:
            self.events.append(
                self.create_event_object(
                    event[0],
                    event[1],
                    int(event[2])))
48212
def create_message(self):
        """"""

        body = dedent("""\
        Received exception {exception} on {queue} from worker {worker}:

        {traceback}

        Payload:
        {payload}

        """).format(exception=self._exception,
                   traceback=self._traceback,
                   queue=self._queue,
                   payload=self._payload,
                   worker=self._worker)

        return MIMEText(body)
520108
function onMessage(message) {
  if (message.command === 'run') {
    run(message.opts);
    return;
  }

  if (message.command === 'stop') {
    cleanup();
  }
}
950396
def capture_message(self, message, level=None):
        # type: (str, Optional[Any]) -> Optional[str]
        
        if self.client is None:
            return None
        if level is None:
            level = "info"
        return self.capture_event({"message": message, "level": level})
1028851
def on_message(self, websocket, msg):
        '''
        '''
        if msg:
            lines = []
            for li in msg.split('\n'):
                li = li.strip()
                if li:
                    lines.append(li)
            msg = ' '.join(lines)
            if msg:
                return self.pubsub.publish(self.channel, msg)
460055
def create_event(self, last_state, state, clean_server_name, replset_name):
        """"""

        status = self.get_state_description(state)
        short_status = self.get_state_name(state)
        last_short_status = self.get_state_name(last_state)
        hostname = self.hostname_for_event(clean_server_name)
        msg_title = "%s is %s for %s" % (hostname, short_status, replset_name)
        msg = "MongoDB %s (%s) just reported as %s (%s) for %s; it was %s before."
        msg = msg % (hostname, clean_server_name, status, short_status, replset_name, last_short_status)

        self.event(
            {
                'timestamp': int(time.time()),
                'source_type_name': self.SOURCE_TYPE_NAME,
                'msg_title': msg_title,
                'msg_text': msg,
                'host': hostname,
                'tags': [
                    'action:mongo_replset_member_status_change',
                    'member_status:' + short_status,
                    'previous_member_status:' + last_short_status,
                    'replset:' + replset_name,
                ],
            }
        )
888370
def _make_event(self, value):  # pylint: disable=arguments-differ
        """"""
        super(SystemLED, self)._make_event(
            self._led_type_code,
            self.code,
            value)
1291975
def trigger_event(event=None, **kwargs):
    '''
    
    '''

    res = {'result': False, 'message': 'Something went wrong'}

    data = {}
    for value in ('value1', 'value2', 'value3',
                  'Value1', 'Value2', 'Value3'):
        if value in kwargs:
            data[value.lower()] = kwargs[value]
    data['occurredat'] = time.strftime("%B %d, %Y %I:%M%p", time.localtime())
    result = _query(event=event,
                    method='POST',
                    data=salt.utils.json.dumps(data)
                    )
    if 'status' in result:
        if result['status'] == 200:
            res['result'] = True
            res['message'] = result['text']
        else:
            if 'error' in result:
                res['message'] = result['error']
    return res
563411
def _emit_message(cls, message):
        """"""
        sys.stdout.write(message)
        sys.stdout.flush()
535081
def emit_event(self, event):
        """"""
        with self._lock:
            listeners = list(self._event_listeners)

        for cb in list(self._event_listeners):
            # noinspection PyBroadException
            try:
                cb(event)
            except:
                # Don't let exceptions from callbacks kill our thread of execution
                logger.exception("Event callback resulted in unhandled exception")
218182
def handle_event(self, packet):
        """"""
        if packet.get('command'):
            task = self.send_command_ack(packet['id'], packet['command'])
            self.loop.create_task(task)