Connect to the notification stream
198982
def _connect_notification(self):
        
        try:
            self._ws = yield from self._session().ws_connect(self._getUrl("/notifications/ws"), auth=self._auth)
        except (aiohttp.WSServerHandshakeError, aiohttp.ClientResponseError):
            self._ws = None
        while self._ws is not None:
            try:
                response = yield from self._ws.receive()
            except aiohttp.WSServerHandshakeError:
                self._ws = None
                break
            if response.tp == aiohttp.WSMsgType.closed or response.tp == aiohttp.WSMsgType.error or response.data is None:
                self._connected = False
                break
            msg = json.loads(response.data)
            action = msg.pop("action")
            event = msg.pop("event")

            if action == "ping":
                self._cpu_usage_percent = event["cpu_usage_percent"]
                self._memory_usage_percent = event["memory_usage_percent"]
                self._controller.notification.emit("compute.updated", self.__json__())
            else:
                yield from self._controller.notification.dispatch(action, event, compute_id=self.id)
        if self._ws:
            yield from self._ws.close()

        # Try to reconnect after 1 seconds if server unavailable only if not during tests (otherwise we create a ressources usage bomb)
        if not hasattr(sys, "_called_from_test") or not sys._called_from_test:
            asyncio.get_event_loop().call_later(1, lambda: asyncio.async(self.connect()))
        self._ws = None
        self._cpu_usage_percent = None
        self._memory_usage_percent = None
        self._controller.notification.emit("compute.updated", self.__json__())
1310029
def _setup_notification_listener(self, topic_name, url):
        """"""

        self.notify_listener = rpc.DfaNotifcationListener(
            topic_name, url, rpc.DfaNotificationEndpoints(self))
8701
def listen(self):
        """"""
        while True:
            message = self.pull.recv()
            logger.debug("received message of length %d" % len(message))
            uuid, message = message[:32], message[32:]
            response = uuid + self.handle(message)
            self.push.send(response)
127419
private void addNotificationListener(ObjectName objectName, final String correlationKey, MBeanServerConnection serverConnection) {
        try {
            notificationListener = new NotificationListener() {
                @Override
                public void handleNotification(Notification notification, Object handback) {
                    correlationManager.store(correlationKey, new DefaultMessage(notification.getMessage()));
                }
            };

            serverConnection.addNotificationListener(objectName, notificationListener, getEndpointConfiguration().getNotificationFilter(), getEndpointConfiguration().getNotificationHandback());
        } catch (InstanceNotFoundException e) {
            throw new CitrusRuntimeException("Failed to find object name instance", e);
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to add notification listener", e);
        }
    }
618936
public void sendNotification(final Notification notification) {

    ContextAwareTimer.Context timer = this.notificationTimer.time();
    if(!this.notificationTargets.isEmpty()) {
        for (final Map.Entry<UUID, Function<Notification, Void>> entry : this.notificationTargets.entrySet()) {
          try {
            entry.getValue().apply(notification);
          } catch (RuntimeException exception) {
            LOG.warn("RuntimeException when running notification target. Skipping.", exception);
          }
        }
    }

    if(getParent().isPresent()) {
      getParent().get().sendNotification(notification);
    }
    timer.stop();
  }
530403
def connect(self):
        """"""
        self.socketIO = SocketIO(
            host=self.iosocket_server,
            port=80,
            resource=self.iosocket_resource,
            proxies=self.proxies,
            headers=self.headers,
            transports=["websocket"],
            Namespace=AtlasNamespace,
        )

        self.socketIO.on(self.EVENT_NAME_ERROR, self.handle_error)
955800
@RequiresApi(api = Build.VERSION_CODES.O)
  public static void setupNotificationChannel() {
    NotificationManager manager
      = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationChannel channel = new NotificationChannel(OfflineConstants.NOTIFICATION_CHANNEL,
      "Offline", NotificationManager.IMPORTANCE_DEFAULT);
    channel.setLightColor(Color.GREEN);
    channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
    manager.createNotificationChannel(channel);
  }
259081
def send_notification(self, method, *args):
        
        message = self._version.create_request(method, args, notification=True)
        self.send_message(message)
624740
private void doConnect(){
        task = new SocketDeamonTask();
        connectThread = new Thread(task);
        connectThread.setDaemon(true);
        connectThread.start();
    }
613387
static void requestNotificationListener(Source source) {
        Intent intent = new Intent(source.getContext(), BridgeActivity.class);
        intent.putExtra(KEY_TYPE, BridgeRequest.TYPE_NOTIFY_LISTENER);
        source.startActivity(intent);
    }
891197
def _on_notification(self, name, args):
        """"""
        if IS_PYTHON3:
            name = decode_if_bytes(name)
        handler = self._notification_handlers.get(name, None)
        if not handler:
            msg = self._missing_handler_error(name, 'notification')
            error(msg)
            self._on_async_err(msg + "\n")
            return

        debug('calling notification handler for "%s", args: "%s"', name, args)
        handler(*args)
236174
def show_notification(cls, channel_id, *args, **kwargs):
        
        app = AndroidApplication.instance()
        builder = Notification.Builder(app, channel_id)
        builder.update(*args, **kwargs)
        return builder.show()
800837
def send_notify(self, playingsong, content=''):
        ''''''
        title = playingsong['title'].decode('utf-8')
        content = content.decode('utf-8')
        if title == self.title:
            if self.has_cover:
                send_notification(self.title, content, self.cover_file.name)
            else:
                send_notification(self.title, content)
        else:
            self.init_notification(playingsong)
            self.title = title
1169486
def send_notification(self, method, args, kwargs):
        """"""
        msg = dumps([1, method, args, kwargs])
        self.send(msg)
912373
def start(self):
        """"""
        self.publish_properties()
        self.subscribe_topics()
        gc.collect()

        self.set_state("ready")

        while True:
            try:
                if not utils.wlan.isconnected():
                    utils.wifi_connect()

                # publish device data
                self.publish_data()

                # check for new mqtt messages
                self.mqtt.check_msg()

                idle()
                sleep(1)
            except KeyboardInterrupt:
                self.set_state("disconnected")
                self.mqtt.disconnect()
1092818
def send(self, notification):
        """"""
        logger.debug('Gateway send notification')

        if self.client is None:
            raise GatewayClientNotSetError()

        yield self.client.send(notification)
116224
async def connect(self):
        
        await self._sender.connect(self._connection(
            self.session.server_address,
            self.session.port,
            self.session.dc_id,
            loop=self._loop,
            loggers=self._log,
            proxy=self._proxy
        ))
        self.session.auth_key = self._sender.auth_key
        self.session.save()

        await self._sender.send(self._init_with(
            functions.help.GetConfigRequest()))

        self._updates_handle = self._loop.create_task(self._update_loop())