Binds given channel events to callbacks.
        :param events: str or list
        :param channels: dict of channel_name: callback_method() pairs
        :return:
552757
def _bind_channels(self, events, channels):
        
        for channel_name in channels:
            if channel_name in self.channels:
                channel = self.pusher.subscribe(channel_name)
                if isinstance(events, list):
                    for event in events:
                        channel.bind(event, channels[channel_name])
                else:
                    channel.bind(events, channels[channel_name])
207102
def events(self, *events):
        
        return self.send_events(self.create_event(e) for e in events)
1265485
def callback(self, output, inputs=None, state=None, events=None):
        ''
        callback_set = {'output':output,
                        'inputs':inputs and inputs or dict(),
                        'state':state and state or dict(),
                        'events':events and events or dict()}
        def wrap_func(func, callback_set=callback_set, callback_sets=self._callback_sets): # pylint: disable=dangerous-default-value, missing-docstring
            callback_sets.append((callback_set, func))
            return func
        return wrap_func
1176616
def connect_ws(self, post_connect_callback, channels, reconnect=False):
        
        self.post_conn_cb = post_connect_callback
        self.channels = channels
        self.wsendpoint = self.context["conf"]["endpoints"].get("websocket")

        # Skip connecting if we don't have any channels to listen to
        if not channels:
            return

        # Create socket, connect, setting callbacks along the way
        self.sock = Socketcluster.socket(self.wsendpoint)
        self.sock.setBasicListener(self._on_connect, self._on_connect_close,
                                   self._on_connect_error)
        self.sock.setAuthenticationListener(self._on_set_auth, self._on_auth)
        self.sock.setreconnection(reconnect)
        self.sock.connect()
1263518
def add_event_callback(channel, callback, bouncetime=None):
    
    _check_configured(channel, direction=IN)

    if bouncetime is not None:
        if _gpio_warnings:
            warnings.warn("bouncetime is not (yet) fully supported, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.", stacklevel=2)

    pin = get_gpio_pin(_mode, channel)
    event.add_edge_callback(pin, __wrap(callback, channel))
808326
function(events, name, callback, context, ctx) {
  if (callback) {
    var handlers = events[name] || (events[name] = []);
    handlers.push({callback: callback, context: context, ctx: context || ctx});
  }
  return events;
}
1164760
def on_connect(self, connection):
        ""
        # NOTE: for python3, we can't pass bytestrings as keyword arguments
        # so we need to decode channel/pattern names back to unicode strings
        # before passing them to [p]subscribe.
        self.pending_unsubscribe_channels.clear()
        self.pending_unsubscribe_patterns.clear()
        if self.channels:
            channels = {}
            for k, v in iteritems(self.channels):
                channels[self.encoder.decode(k, force=True)] = v
            self.subscribe(**channels)
        if self.patterns:
            patterns = {}
            for k, v in iteritems(self.patterns):
                patterns[self.encoder.decode(k, force=True)] = v
            self.psubscribe(**patterns)
657090
def trigger(self_, *param_names):
        
        events = self_.self_or_cls.param._events
        watchers = self_.self_or_cls.param._watchers
        self_.self_or_cls.param._events  = []
        self_.self_or_cls.param._watchers = []
        param_values = dict(self_.get_param_values())
        params = {name: param_values[name] for name in param_names}
        self_.self_or_cls.param._TRIGGER = True
        self_.set_param(**params)
        self_.self_or_cls.param._TRIGGER = False
        self_.self_or_cls.param._events = events
        self_.self_or_cls.param._watchers = watchers
815750
def join_channel(self, channel, key=None, tags=None):
        """"""
        params = [channel]
        if key:
            params.append(key)
        self.send('JOIN', params=params, tags=tags)
1148533
def set_read_events_callback(self, call_back):
        
        logger.info("setting read event callback")
        callback_wrapper = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
                                            ctypes.POINTER(snap7.snap7types.SrvEvent),
                                            ctypes.c_int)

        def wrapper(usrptr, pevent, size):
            """
            Wraps python function into a ctypes function

            :param usrptr: not used
            :param pevent: pointer to snap7 event struct
            :param size:
            :returns: should return an int
            """
            logger.info("callback event: " + self.event_text(pevent.contents))
            call_back(pevent.contents)
            return 0

        self._read_callback = callback_wrapper(wrapper)
        return self.library.Srv_SetReadEventsCallback(self.pointer,
                                                      self._read_callback)
626397
def send_events(self, events):
        
        for event in events:
            self.queue.events.add().MergeFrom(event)
        return None
875309
def subscribe_to_events(config, subscriber, events, model=None):
    
    kwargs = {}
    if model is not None:
        kwargs['model'] = model

    for evt in events:
        config.add_subscriber(subscriber, evt, **kwargs)
511964
def for_events(*events):
    
    events = set(events)

    def wrap(func):
        func.event_types = events
        return func

    return wrap
509434
def _setup_events(plugin):
    

    events = plugin.events

    if events and isinstance(events, (list, tuple)):
        for event in [e for e in events if e in _EVENT_VALS]:
            register('event', event, plugin)
1267655
def enable_events(self, event_callback=None) -> None:
        """"""
        self.event = EventManager(event_callback)
        self.stream.event = self.event
364023
public EventsBatch withEvents(java.util.Map<String, Event> events) {
        setEvents(events);
        return this;
    }
99715
def event_return(events):
    '''
    
    '''
    conn, mdb = _get_conn(ret=None)

    if isinstance(events, list):
        events = events[0]

    if isinstance(events, dict):
        log.debug(events)

        if PYMONGO_VERSION > _LooseVersion('2.3'):
            mdb.events.insert_one(events.copy())
        else:
            mdb.events.insert(events.copy())