Handle notifications that arrive

Parse notification from event and process any commands cound within

@private

@param {*} data Notification data
@returns {Promise} Resolved when any commands contained in notificaiton have been processed
357196
function notifyHandler(data) {
        const notification = Notification.parse(data);
        return evalBlacklist(notification)
            .then(() => {
                forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
    
                const ids = {
                    post: notification.postId,
                    topic: notification.topicId,
                    user: notification.userId,
                    pm: -1,
                    chat: -1
                };
                return notification.getText()
                    .then((postData) => forum.Commands.get(ids,
                        postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content)))
                    .then((commands) => {
                        if (commands.commands.length === 0) {
                            debug(`Emitting events: 'notification' and 'notification:${notification.type}'`);
                            forum.emit(`notification:${notification.type}`, notification);
                            forum.emit('notification', notification);
                        }
                        return commands;
                    })
                    .then((commands) => commands.execute());
            }).catch((err) => {
                if (err === 'Ignoring notification') {
                //We do not process the notification, but we can continue with life
                    return Promise.resolve();
                }
                throw err;
            });
    }
483466
function handle(msg) {
  log.debug('handling msg', msg)
  var to = msg.to,
    intent = msg.intent;
  if (to && intent) {
    var reply;
    // try JSON or JSON.input as input
    try {
      reply = _.get(lib_js[to], intent)(msg)
    } catch (err) {
      try {
        reply = _.get(lib_js[to], intent)(msg.input)
      } catch (deepErr) {
        log.debug('js handle fails.', deepErr)
      }
    } finally {
      // try JSON or made-JSON output
      reply = correctReply(reply, msg)
      log.debug('reply', reply)
      if (reply.to) {
        client.emit('pass', reply)
      }
    }
  }
}
768007
function (messageData) {
		if (status.enabled) {
			var messageObject = JSON.parse(messageData);
			if ((messageObject || {})
				.id) {
				switch (messageObject.action) {
				case MESSENGER_CONST.ACTION.ECHIP_SET:
					onSetRequestCallback(messageObject.data, function () {
						setRequestResponse(messageObject.id);
					});
					break;
				case MESSENGER_CONST.ACTION.ECHIP_GET:
					onGetRequestCallback(messageObject.data, function (data) {
						getRequestResponse(messageObject.id, data);
					});
					break;
				}
			}
		}
	}
439990
def handleNotification(self, handle, raw_data):  # pylint: disable=unused-argument,invalid-name
        
        if raw_data is None:
            return
        data = raw_data.decode("utf-8").strip(' \n\t')
        self._cache = data
        self._check_data()
        if self.cache_available():
            self._last_read = datetime.now()
        else:
            # If a sensor doesn't work, wait 5 minutes before retrying
            self._last_read = datetime.now() - self._cache_timeout + \
                timedelta(seconds=300)
332263
function(title, message, cb, okText) {
    cb = cb || function() {};
    title = title || '';
    okText = okText || gettextCatalog.getString('OK');
    $window.top.navigator.notification.alert(message, cb, title, okText);
  }
1170118
function Message(data, source){
	source = source || {}
	this.data = data
	this.key = source.key
	this.sourceChannel = source.name
}
823524
function handleIncomingMessage(data) {
		var message;
		reader.parse(data, initPending);
		initPending = false;
		while (!reader.isEmpty()) {
			message = reader.pop();
			// console.log("IN MESSAGE: " + inspect(message));
			// Check if there are listeners attached to the event
			// otherwise falls back to the default handler
			if (that.listeners(message.verb).length) {
				handlers[message.verb](message);
			} else {
				defHandlers[message.verb].call(that, message);
			}
		}
	}
327330
def process_notifications(self, messages):
        """"""
        for object_id, object_size, metadata_size in messages:
            if object_size > 0 and object_id in self._waiting_dict:
                linked_list = self._waiting_dict[object_id]
                self._complete_future(linked_list)
106704
function onServerMessage(data)
    {
        if(data.ev)
        {
            scope.dispatchEvent("onServerMessage",data);
            scope.dispatchEvent(data.ev,data);
        }
    }
440448
def wrap_notification(self, data):
        """"""
        if "method" in data:
            method = data["method"]
            params = data["params"]
            change = params[0]
            if method == "notifyPowerStatus":
                return PowerChange.make(**change)
            elif method == "notifyVolumeInformation":
                return VolumeChange.make(**change)
            elif method == "notifyPlayingContentInfo":
                return ContentChange.make(**change)
            elif method == "notifySettingsUpdate":
                return SettingChange.make(**change)
            elif method == "notifySWUpdateInfo":
                return SoftwareUpdateChange.make(**change)
            else:
                _LOGGER.warning("Got unknown notification type: %s", method)
        elif "result" in data:
            result = data["result"][0]
            if "enabled" in result and "enabled" in result:
                return NotificationChange(**result)
        else:
            _LOGGER.warning("Unknown notification, returning raw: %s", data)
            return data
996203
def process_notification(notification)
      Flapjack.logger.debug { "Processing notification: #{notification.inspect}" }

      check       = notification.check
      check_name  = check.name

      # TODO check whether time should come from something stored in the notification
      alerts = alerts_for(notification, check, :time => Time.now)

      if alerts.nil? || alerts.empty?
        Flapjack.logger.info { "No alerts" }
      else
        Flapjack.logger.info { "Alerts: #{alerts.size}" }

        alerts.each do |alert|
          medium = alert.medium

          Flapjack.logger.info {
            "#{check_name} | #{medium.contact.id} | " \
            "#{medium.transport} | #{medium.address}\n" \
            "Enqueueing #{medium.transport} alert for " \
            "#{check_name} to #{medium.address} " \
            " rollup: #{alert.rollup || '-'}"
          }

          @queues[medium.transport].push(alert)
        end
      end

      notification.destroy
    end
377505
@Override
    public void handleNotification(Notification notification, Object handback) {
       try {
           method.invoke(target, notification, handback);
       } catch (Exception e) {
           LOG.error("Could not invoke MessageListener method " + method + " on " + target, e);
       }
        
    }
577273
def fetch(self, *args, **kwargs):
        
        response = client.get('/tables/Notifications/{0}'.format(self.id))
        self._update_data(response.json())
901373
function showNotification(data) {
  if (!data || !data.tag) {
    // eslint-disable-next-line no-param-reassign
    data = $Notifications.default;
  }
  logger.group(data.tag);
  logger.log('Show notification.', data.tag);
  return self.registration
    .showNotification(data.title, data)
    .then(delayDismissNotification);
}
452648
@Override
    public void handleNotification(Notification notification, Object handback) {
        String notificationType = notification.getType();
        if (notificationType.equals(JMXConnectionNotification.OPENED)) {
            managementContext.incrementManagementSessionCount();
        } else if (notificationType.equals(JMXConnectionNotification.CLOSED)) {
            managementContext.decrementManagementSessionCount();
        }
    }
677654
async def notifications(dev: Device, notification: str, listen_all: bool):
    
    notifications = await dev.get_notifications()

    async def handle_notification(x):
        click.echo("got notification: %s" % x)

    if listen_all:
        if notification is not None:
            await dev.services[notification].listen_all_notifications(
                handle_notification
            )
        else:
            click.echo("Listening to all possible notifications")
            await dev.listen_notifications(fallback_callback=handle_notification)

    elif notification:
        click.echo("Subscribing to notification %s" % notification)
        for notif in notifications:
            if notif.name == notification:
                await notif.activate(handle_notification)

        click.echo("Unable to find notification %s" % notification)

    else:
        click.echo(click.style("Available notifications", bold=True))
        for notification in notifications:
            click.echo("* %s" % notification)
679724
function fixEventPayload(events) {
    return new Promise(function (resolve, reject) {
        events.forEach(function(event) {
            try {
                event.payload = JSON.parse(event.payload);
            } catch (e) {
                console.log('Could not parse payload');
                return reject(new Error('Could not parse payload: ' + e.message));
            }
        });
        resolve();
    });
}