Opening the class on which the notify functionality is applied.
764225
def open_notified_class
      class_eval do
        prepend NotificationActions
        attr_accessor :message, :notify_flag

        # Define association for the notified model
        has_many :notifications, class_name: 'SimpleNotifications::Record', as: :entity
        has_many :notifiers, through: :notifications, source: :sender, source_type: sender_class(@@options[:sender]).to_s
        has_many :read_deliveries, through: :notifications, source: :read_deliveries
        has_many :unread_deliveries, through: :notifications, source: :unread_deliveries

        # Callbacks
        after_create_commit :create_notification, if: proc {@@options[:callbacks].include?(:create)}
        after_update_commit :update_notification, if: proc {@@options[:callbacks].include?(:update)}
        after_destroy_commit :destroy_notification, if: proc {@@options[:callbacks].include?(:destroy)}

        NotificationActions.module_eval do
          @@options[:actions].each do |action|
            define_method(action) do
              run_callbacks action do
                super()
              end
            end

            define_method("before_#{action}".to_sym) do
            end

            define_method("after_#{action}".to_sym) do
              self.notify(sender: @@options[:sender], receivers: @@options[:receivers], message: default_message(self, @@options[:sender], action.to_s))
            end
          end
        end

        @@options[:actions].each do |action|
          define_model_callbacks action
          send("before_#{action}", "before_#{action}".to_sym)
          send("after_#{action}", "after_#{action}".to_sym)
        end

        #Example
        #post.notify(sender: :author, receivers: :followers, message: 'My Custom logic message')
        #post.create(content: '', notify: false) -> It does not create the notification.
        def notify(options = {})
          options[:sender] ||= @@options[:sender]
          options[:receivers] ||= @@options[:receivers]
          if notify_flag.nil? || (!notify_flag.nil? && !!notify_flag)
            raise 'SimpleNotification::SenderReceiverError' unless @@options[:sender] && @@options[:receivers]
            @message = options[:message] if options[:message]
            notification = notifications.build(entity: self, sender: get_obj(options[:sender]), message: default_message(self, get_obj(options[:sender]), 'created'))
            get_obj(options[:receivers]).each {|receiver| notification.deliveries.build(receiver: receiver)}
            notification.save
          end
        end

        def flush_notifications
          notifications.destroy_all
        end

        # Check if notifications has already been delivered.
        def notified?
          !notifications.blank?
        end

        def notificants
          SimpleNotifications::Record.includes(deliveries: :receiver)
              .collect(&:deliveries).flatten
              .collect(&:receiver)
        end

        def read_marked_notificants
          SimpleNotifications::Record.includes(deliveries: :receiver)
              .collect(&:deliveries).flatten
              .select{|record| record.is_read}
              .collect(&:receiver)
        end

        def unread_marked_notificants
          SimpleNotifications::Record.includes(deliveries: :receiver)
              .collect(&:deliveries).flatten
              .select{|record| !record.is_read}.collect(&:receiver)
        end

        # Mark notifications in read mode.
        # If notificants are provided then only those respective notifications will be marked read.
        # Else all will be marked as read.
        def mark_read(notificants = nil)
          (notificants ? unread_deliveries.where(receiver: notificants) : unread_deliveries).update_all(is_read: true)
        end

        # Mark notifications in unread mode.
        # If notificants are provided then only those respective notifications will be marked unread.
        # Else all will be marked as unread.
        def mark_unread(notificants = nil)
          (notificants ? read_deliveries.where(receiver: notificants) : read_deliveries).update_all(is_read: false)
        end

        def default_message(entity, sender, action)
          @message || (method(@@options[:notify_message]).call if !!@@options[:notify_message]) || "#{get_obj(sender).class.name} #{action} #{entity.class.name} #{entity.name}."
        end

        private

        def get_obj(sender_or_receivers)
          sender_or_receivers.kind_of?(Symbol) ? send(sender_or_receivers) : sender_or_receivers
        end

        def create_notification
          notify({sender: get_obj(@@options[:sender]), receivers: get_obj(@@options[:receivers]), message: default_message(self, get_obj(@@options[:sender]), 'created')})
        end

        def update_notification
          notify({sender: get_obj(@@options[:sender]), receivers: get_obj(@@options[:receivers]), message: default_message(self, get_obj(@@options[:sender]), 'updated')})
        end

        def destroy_notification
          notify({sender: get_obj(@@options[:sender]), receivers: get_obj(@@options[:receivers]), message: default_message(self, get_obj(@@options[:sender]), 'deleted')})
        end
      end
    end
674619
protected void dispatchNotifications ()
    {
        for (int ii = 0, nn = _notify.size(); ii < nn; ii++) {
            Tuple<ObserverList<Object>,ObserverOp<Object>> tuple = _notify.get(ii);
            tuple.left.apply(tuple.right);
        }
        _notify.clear();
    }
149386
private void requestNotification() {
        AndPermission.with(this)
            .notification()
            .permission()
            .rationale(new NotifyRationale())
            .onGranted(new Action<Void>() {
                @Override
                public void onAction(Void data) {
                    toast(R.string.successfully);
                }
            })
            .onDenied(new Action<Void>() {
                @Override
                public void onAction(Void data) {
                    toast(R.string.failure);
                }
            })
            .start();
    }
1228576
@RestrictTo(LIBRARY)
	public void notifyUseCaseStart(UseCaseListener listener) {
		try {
			LOGGER.debug("Notifying " + getClass().getSimpleName() + " start to listener " + listener.getClass().getSimpleName());
			listener.onStartUseCase();
		} catch (Exception e) {
			AbstractException abstractException = wrapException(e);
			logHandledException(abstractException);
		}
	}
1084509
def __notify(self):
        
        if self.__callback is not None:
            try:
                self.__callback(
                    self._done_event.data,
                    self._done_event.exception,
                    self.__extra,
                )
            except Exception as ex:
                self._logger.exception("Error calling back method: %s", ex)
1326377
private <T extends Rdp4jListener> void notifyListeners(Class<T> listenerType, Notifier<T> notifier)
            throws InterruptedException {
        for (Rdp4jListener listener : listeners) {
            if (isInstanceOf(listener, listenerType)) {
                /*
                 * This cast is correct, since we check if listener
                 * is instance of listenerType.
                 */
                @SuppressWarnings("unchecked")
                T listener2 = (T) listener;
                try {
                    notifier.notify(listener2);
                } catch (InterruptedException e) {
                    throw e;
                } catch (Throwable e) {
                    logErrorMessage(e);
                }
            }
        }
    }
1311602
function (options) {
                var self = this;
                options = self.getOptions(options);
                var existing = $('.' + NOTIFICATIONS_CONTAINER_CLASS + ' > div');
                if (existing) {
                    var diff = existing.length - options.maxNotifications;
                    if (diff >= 0) {
                        for (var i = 0, _i = diff + 1; i < _i; i++) {
                            this.closeNotification(existing[i], -1);
                        }
                    }
                }

                this.buildNotification(options);
            }
1326416
public void classAvailable(Class<?> clazz) {
        if (!isMonitorable(clazz)) {
            return;
        }
        listenersLock.readLock().lock();
        try {
            for (ProbeListener listener : allRegisteredListeners) {
                ProbeFilter filter = listener.getProbeFilter();
                if (filter.matches(clazz)) {
                    addInterestedByClass(clazz, Collections.singleton(listener));
                }
            }
        } finally {
            listenersLock.readLock().unlock();
        }

        // Update the new class with the configured probes
        if (!getInterestedByClass(clazz).isEmpty()) {
            this.transformer.instrumentWithProbes(Collections.<Class<?>> singleton(clazz));
        }
    }
1086829
public A notificationClass(DeliveryClass delivery) {
        this.headers.add(Pair.of("X-NotificationClass", String.valueOf(deliveryValueOf(delivery))));
        return (A)this;
    }
356968
def on_click(self, event):
        
        if not self.notification:
            return

        if self.charging:
            format = self.format_notify_charging
        else:
            format = self.format_notify_discharging

        message = self.py3.safe_format(
            format,
            dict(
                ascii_bar=self.ascii_bar,
                icon=self.icon,
                percent=self.percent_charged,
                time_remaining=self.time_remaining,
            ),
        )

        if message:
            self.py3.notify_user(message, "info")
163926
function (notifyText) {
			this.writeDebug('notify',notifyText);
			if (this.settings.callbackNotify) {
				this.settings.callbackNotify.call(this, notifyText);
			}
			else {
				alert(notifyText);
			}
		}
1310028
function () {
            /*  determine parameters  */
            var params = $cs.params("notify", arguments, {
                name:    { pos: 0,     req: true                                          },
                args:    { pos: "...", def: []                                            },
                matches: {             def: function (p, l) { return p.name === l.name; } } /* customized matching */
            });

              */
            for (var id in this.__listener) {
                if (_cs.isown(this.__listener, id)) {
                    var listener = this.__listener[id];
                    if (params.matches(params, listener)) {
                        var args = _cs.concat(listener.args, params.args);
                        listener.func.apply(listener.ctx, args);
                    }
                }
            }
        }
138279
@Override
    public void notifyHandlableAdded(Featurable featurable)
    {
        if (featurable.hasFeature(Displayable.class))
        {
            final Displayable displayable = featurable.getFeature(Displayable.class);
            final Integer layer = getLayer(featurable);
            final Collection<Displayable> displayables = getLayer(layer);
            displayables.add(displayable);
            indexs.add(layer);
        }
    }
319294
@Override
    public void notificationCreated(RuntimeUpdateManager updateManager, RuntimeUpdateNotification notification) {

        // CONFIG_UPDATES_DELIVERED notification actually indicates that a config update is starting. The update
        // won't be complete until the future we get from the notification is complete.
        if (RuntimeUpdateNotification.CONFIG_UPDATES_DELIVERED.equals(notification.getName())) {

            configFuture = notification.getFuture();
            _futureMonitor.onCompletion(notification.getFuture(), new CompletionListener<Boolean>() {
                @Override
                public void successfulCompletion(Future<Boolean> future, Boolean result) {
                    // We're done with the update. Set the configFuture to null, and submit a dummy task
                    // so that performAction knows it can kick off the executor.
                    configFuture = null;
                    submit();
                }

                @Override
                public void failedCompletion(Future<Boolean> future, Throwable t) {
                    // The update failed, but we still want to process any queued actions. Set the
                    // configFuture to null, and submit a dummy task so that performAction knows
                    // it can kick off the executor.
                    configFuture = null;
                    submit();
                }

                // Submit a dummy job so that performAction() will kick off the executor for the actions queue
                private void submit() {
                    synchronized (actionQueue) {
                        performAction(new Runnable() {

                            @Override
                            public void run() {
                                return;
                            }
                        });
                    }
                }
            });
        }

    }
1113387
def notify(message, message_opts = {})
      if _client?
        return unless enabled?
      else
        return unless active?
      end

      @detected.available.each do |notifier|
        notifier.notify(message, message_opts.dup)
      end
    end
234107
def notify(options = {})
      @@options = options
      @@options[:entity_class] = self
      @@options[:callbacks] = []
      [:create, :update, :destroy].each {|_method| @@options[:callbacks] << @@options[:actions].delete(_method)}
      @@options[:callbacks].compact!
      open_sender_class
      open_receiver_class
      open_notified_class
      @@notified_flag = true
    end
80804
function() {
      if (node.debug) {
        node.log('STARTING event listener');
      }

      var net = require('net');
      var dgram = require('dgram');
      node.inputSocket = dgram.createSocket({type:'udp4', reuseAddr: true});

      node.inputSocket.on('notify', function (event) {
        if (node.debug) {
          node.log('Got a notification.', event)
        }
      });

      node.inputSocket.on('message', function (msg, rinfo) {
        //node.log("[" + rinfo.address + "] --> " + msg.toString());

        if (rinfo.address == node.address) {
          if (node.debug) {
            node.log("UPnP Event from [" + rinfo.address + "] --> " );//+ msg.toString());
          }

          // Split to header and body
          msg = msg.toString().split('\r\n\r\n');
          var header = msg[0];
          var body = msg[1];

          // Ignore UPNP search requests
          var method = header.split('\r\n').shift().split(' ').shift().trim();
          if (method == 'M-SEARCH'){
            return;
          }

          // Parse rest of header
          var arr = header.match(/[^\r\n]+/g);
          var headerInfo = {};
          for (var i = 1; i < arr.length; ++i){
            var tem = arr[i].split(/:(.+)?/);
            if (typeof(tem[1]) == 'string'){ tem[1] = tem[1].trim(); }
            headerInfo[tem[0].toLowerCase()] = tem[1];
          };
          //node.log("METHOD: " + method);
          //node.log("BODY: " + body);
          //node.log("NTS: " + headerInfo['nts']);

          // NOTIFY messages tell us about the properties that changed
          if (method == 'NOTIFY' && headerInfo['nts'] == 'yamaha:propchange') {

            var parseString = require('xml2js').parseString;
            parseString(body, function (err, result) {
              if (err) {
                node.error('Failed to parse the event with error: ' + err);
                return;
              }

              // Check the received object
              var zoneName = undefined;
              if (result.hasOwnProperty('YAMAHA_AV')) {
                if (result.YAMAHA_AV.hasOwnProperty('Main_Zone')) {
                  zoneName = 'Main_Zone';
                } else if (result.YAMAHA_AV.hasOwnProperty('Zone_2')) {
                  zoneName = 'Zone_2';
                } else if (result.YAMAHA_AV.hasOwnProperty('Zone_3')) {
                  zoneName = 'Zone_3';
                } else if (result.YAMAHA_AV.hasOwnProperty('Zone_4')) {
                  zoneName = 'Zone_4';
                }
              }
              if (zoneName === undefined
                || result.YAMAHA_AV[zoneName] === undefined
                || result.YAMAHA_AV[zoneName][0] === undefined) {
                if (node.debug) {
                  node.warn('Unknown event message format: ' + JSON.stringify(result));
                }
                return;
              }

              for (var i in result.YAMAHA_AV[zoneName][0].Property) {
                var prop = result.YAMAHA_AV[zoneName][0].Property[i];
                if (node.debug) {
                  node.log('Property-Change: ' + prop);
                }

                // Event Notification only notifies that there is a change in each item.
                // It is necessary to issue the GET command to obtain the content of the item with the change.
                if (prop == 'Power') {

                  // Get current power state and publish to all subscriber.
                  node.sendGetCommand(zoneName + '.Power_Control.Power').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Power_Control.Power', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });

                } else if (prop == 'Input') {

                  // Get current input selection and publish to all subscriber.
                  node.sendGetCommand(zoneName + '.Input.Input_Sel').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Input.Input_Sel', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });

                } else if (prop == 'Volume') {

                  // We don't know from the event itself if volume changed or mute/unmute was pressed.
                  // Therefore we read both states.
                  node.sendGetCommand(zoneName + '.Volume.Lvl').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Volume.Lvl', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });
                  node.sendGetCommand(zoneName + '.Volume.Mute').then(function(value) {
                    for (var s in node.subscriptions) {
                      node.subscriptions[s].handler(zoneName + '.Volume.Mute', value);
                    }
                  }).catch(function(error) {
                    node.error('Failed to request data from AVR with error: ' + error);
                  });

                } else if (prop == 'Play_Info') {

                  // When getting the Play_Info event we need to check the current input mode and then read
                  // the corresponding item that holds info about current mode.
                  node.sendGetCommand(zoneName + '.Input.Input_Sel').then(function(value) {

                    var validInputs = {
                      'TUNER': 'Tuner', 'Napster': 'Napster', 'Spotify': 'Spotify', 'JUKE': 'JUKE', 'SERVER': 'SERVER',
                      'NET RADIO': 'NET_RADIO', 'USB': 'USB', 'iPod_USB': 'iPod_USB', 'AirPlay': 'AirPlay'
                    };

                    if (validInputs.hasOwnProperty(value)) {
                      node.sendGetCommand(validInputs[value] + '.Play_Info').then(function(value2) {
                        for (var s in node.subscriptions) {
                          node.subscriptions[s].handler(value + '.Play_Info', value2);
                        }
                      }).catch(function(error) {
                        node.error('Received event Play_Info but failed to read play info of current input selection: ' + error);
                      });
                    } else {
                      if (node.debug) {
                        node.log('Received event Play_Info but do not know or support current input selection ' + value);
                      }
                    }
                  }).catch(function(error) {
                    node.error('Received event Play_Info but failed to read current input selection: ' + error);
                  });

                } else if (prop == 'List_Info') {

                  // When getting the List_info event we need to check the current input mode and then read
                  // the corresponding item that holds info about current mode.
                  node.sendGetCommand(zoneName + '.Input.Input_Sel').then(function(value) {

                    var validInputs = {
                      'Napster': 'Napster', 'JUKE': 'JUKE', 'SERVER': 'SERVER',
                      'NET RADIO': 'NET_RADIO', 'USB': 'USB', 'iPod_USB': 'iPod_USB'
                    };

                    if (validInputs.hasOwnProperty(value)) {
                      node.sendGetCommand(validInputs[value] + '.List_Info').then(function(value2) {
                        for (var s in node.subscriptions) {
                          node.subscriptions[s].handler(value + '.List_Info', value2);
                        }
                      }).catch(function(error) {
                        node.error('Received event List_Info but failed to read play info of current input selection: ' + error);
                      });
                    } else {
                      if (node.debug) {
                        node.log('Received event List_Info but do not know or support current input selection ' + value);
                      }
                    }
                  }).catch(function(error) {
                    node.error('Received event List_Info but failed to read current input selection: ' + error);
                  });

                } else {

                  // The event is not known. Maybe the AVR is too new.
                  if (node.debug) {
                    node.log('Received unsupported Property-Change via multicast: ' + prop);
                  }
                  return;

                }
              }
            });
          }
        }
      });

      node.inputSocket.on('listening', function () {
        try {
          var address = node.inputSocket.address();
          node.log('UDP client listening on ' + address.address + ":" + address.port);
          node.inputSocket.setBroadcast(true)
          node.inputSocket.setMulticastTTL(5);
          node.inputSocket.addMembership('239.255.255.250');
          //node.inputSocket.addMembership('239.255.255.250', '192.168.0.101');
          //node.inputSocket.addMembership('239.255.255.250', '127.0.0.1');

          /*
          var message = new Buffer(
            "M-SEARCH * HTTP/1.1\r\n" +
            "HOST: 239.255.255.250:1900\r\n" +
            "MAN: \"ssdp:discover\"\r\n" +
            "ST: ssdp:all\r\n" + // Essential, used by the client to specify what they want to discover, eg 'ST:ge:fridge'
            "MX: 3\r\n" + // 1 second to respond (but they all respond immediately?)
            "\r\n");
          */

            //node.inputSocket.send(message, 0, message.length, 1900, "239.255.255.250");
          } catch (err) {
            node.warn('Cannot bind address for UPNP event listener. Port probably already in use. Error: ' + err);
          }
        });

      try {
        node.inputSocket.bind(1900);
      }
      catch (err) {
        node.warn('Cannot bind address for UPNP event listener. Port probably already in use. Error: ' + err);
      }
    }