Constructs prefix notification with data from given outgoing message.

    Given RPC session is used to create RPC notification message.
182010
def _create_prefix_notification(outgoing_msg, rpc_session):
    
    assert outgoing_msg
    path = outgoing_msg.path
    assert path
    vpn_nlri = path.nlri

    assert path.source is not None
    if path.source != VRF_TABLE:
        # Extract relevant info for update-add/update-delete.
        params = [{ROUTE_DISTINGUISHER: outgoing_msg.route_dist,
                   PREFIX: vpn_nlri.prefix,
                   NEXT_HOP: path.nexthop,
                   VRF_RF: VrfConf.rf_2_vrf_rf(path.route_family)}]
        if path.nlri.ROUTE_FAMILY.safi not in (subaddr_family.IP_FLOWSPEC,
                                               subaddr_family.VPN_FLOWSPEC):
            params[VPN_LABEL] = path.label_list[0]

        if not path.is_withdraw:
            # Create notification to NetworkController.
            rpc_msg = rpc_session.create_notification(
                NOTIFICATION_ADD_REMOTE_PREFIX, params)
        else:
            # Create update-delete request to NetworkController.
            rpc_msg = rpc_session.create_notification(
                NOTIFICATION_DELETE_REMOTE_PREFIX, params)
    else:
        # Extract relevant info for update-add/update-delete.
        params = [{ROUTE_DISTINGUISHER: outgoing_msg.route_dist,
                   PREFIX: vpn_nlri.prefix,
                   NEXT_HOP: path.nexthop,
                   VRF_RF: VrfConf.rf_2_vrf_rf(path.route_family),
                   ORIGIN_RD: path.origin_rd}]
        if not path.is_withdraw:
            # Create notification to NetworkController.
            rpc_msg = rpc_session.create_notification(
                NOTIFICATION_ADD_LOCAL_PREFIX, params)
        else:
            # Create update-delete request to NetworkController.
            rpc_msg = rpc_session.create_notification(
                NOTIFICATION_DELETE_LOCAL_PREFIX, params)

    return rpc_msg
1291994
def create_message(self):
        """"""
        self.counter += 1
        self._transport.send(
            "transient.transaction",
            "TXMessage #%d\n++++++++Produced@ %f"
            % (self.counter, (time.time() % 1000) * 1000),
        )
        self.log.info("Created message %d", self.counter)
542100
def _add_notification(self, message):
        
        sess = cherrypy.session
        username = sess.get(SESSION_KEY, None)
        if username not in self.notifications:
            self.notifications[username] = []
        self.notifications[username].append(message)
106883
def compile_msg_payload(self, invite):
        
        self.l.info("Compiling the outbound message payload")
        update_invite = False

        # Determine the recipient address
        if "to_addr" in invite.invite:
            to_addr = invite.invite["to_addr"]
        else:
            update_invite = True
            to_addr = get_identity_address(invite.identity)

        # Determine the message content
        if "content" in invite.invite:
            content = invite.invite["content"]
        else:
            update_invite = True
            content = settings.INVITE_TEXT

        # Determine the metadata
        if "metadata" in invite.invite:
            metadata = invite.invite["metadata"]
        else:
            update_invite = True
            metadata = {}

        msg_payload = {
            "to_addr": to_addr,
            "content": content,
            "metadata": metadata
        }

        if update_invite is True:
            self.l.info("Updating the invite.invite field")
            invite.invite = msg_payload
            invite.save()

        self.l.info("Compiled the outbound message payload")
        return msg_payload
161994
def message(message_type, payload, payload_length):
    
    return packet.build(
        Container(
            type=message_type,
            id=1,
            refer=0,
            sent=Container(
                secs=0,
                usecs=0
            ),
            recv=Container(
                secs=0,
                usecs=0
            ),
            payload_length=payload_length,
            payload=payload
        )
    )
1294785
def QueueNotification(self, notification=None, timestamp=None, **kw):
    """"""

    if notification is None:
      notification = rdf_flows.GrrNotification(**kw)

    session_id = notification.session_id

    if session_id:
      if timestamp is None:
        timestamp = self.frozen_timestamp

      notification.timestamp = timestamp

      # We must not store more than one notification per session id and
      # timestamp or there will be race conditions. We therefore only keep
      # the one with the highest request number (indicated by last_status).
      # Note that timestamp might be None. In that case we also only want
      # to keep the latest.
      if timestamp is None:
        ts_str = "None"
      else:
        ts_str = int(timestamp)
      key = "%s!%s" % (session_id, ts_str)
      existing = self.notifications.get(key)
      if existing is not None:
        if existing.last_status < notification.last_status:
          self.notifications[key] = notification
      else:
        self.notifications[key] = notification
327372
public static void sendNotification (
        ClientObject target, String receiverCode, int methodId, Object[] args, Transport transport)
    {
        // convert the receiver hash id into the code used on this
        // specific client
        Registration rreg = target.receivers.get(receiverCode);
        if (rreg == null) {
            log.warning("Unable to locate receiver for invocation service notification",
                        "clobj", target.who(), "code", receiverCode, "methId", methodId,
                        "args", args, new Exception());

        } else {
//             log.info("Sending notification", "target", target, "code", receiverCode,
//                      "methodId", methodId, "args", args);

            // create and dispatch an invocation notification event
            target.postEvent(new InvocationNotificationEvent(
                                 target.getOid(), rreg.receiverId, methodId, args).
                             setTransport(transport));
        }
    }
490912
private void sendNotification(String errMessage, int errCode, String errType, boolean createNotification) {
        NotificationsDao notifications = storage.getNotificationsDao();
        Notification notification;

        if (errType == "warning") {
            logger.warning(errMessage); // send message to console
            if (createNotification) {
                notification = notification(WARNING_NOTIFICATION, errCode, errMessage);
                notifications.addNotification(notification);
            }
        } else if (errType == "error") {
            logger.error(errMessage); // send message to console
            if (createNotification) {
                notification = notification(ERROR_NOTIFICATION, errCode, errMessage);
                notifications.addNotification(notification);
            }
        } else if (errType == "info") {
            if (logger.isInfoEnabled()) {
                logger.info(errMessage); // send message to console
            }
        }
    }
806955
def construct(self, max_message_size, remote_name=None, python_path=None,
                  debug=False, connect_timeout=None, profiling=False,
                  unidirectional=False, old_router=None, **kwargs):
        """"""
        super(Stream, self).construct(**kwargs)
        self.max_message_size = max_message_size
        if python_path:
            self.python_path = python_path
        if connect_timeout:
            self.connect_timeout = connect_timeout
        if remote_name is None:
            remote_name = get_default_remote_name()
        if '/' in remote_name or '\\' in remote_name:
            raise ValueError('remote_name= cannot contain slashes')
        self.remote_name = remote_name
        self.debug = debug
        self.profiling = profiling
        self.unidirectional = unidirectional
        self.max_message_size = max_message_size
        self.connect_deadline = time.time() + self.connect_timeout
1356778
def handle_request(message, notification=false, connection={})
    # get client for the specified connection
    # TODO should grap port/ip immediately on connection and use that
    client_port,client_ip = client_for(connection)

    msg = notification ?
      Messages::Notification.new(:message => message,
                                 :headers => @message_headers) :
           Messages::Request.new(:message => message,
                                 :headers => @message_headers)

    callback = NodeCallback.new(:node       => self,
                                :connection => connection)

    result = @dispatcher.dispatch(:rjr_method      => msg.jr_method,
                                  :rjr_method_args => msg.jr_args,
                                  :rjr_headers     => msg.headers,
                                  :rjr_client_ip   => client_ip,
                                  :rjr_client_port => client_port,
                                  :rjr_node        => self,
                                  :rjr_node_id     => node_id,
                                  :rjr_node_type   => self.node_type,
                                  :rjr_callback    => callback)

    unless notification
      response = Messages::Response.new(:id      => msg.msg_id,
                                        :result  => result,
                                        :headers => msg.headers,
                                        :request => msg)
      self.send_msg(response.to_s, connection)
      return response
    end

    nil
  end
71726
def received_message(self, address, data):
        """"""
        self.value_cache.set(address, data)
        if self.notify:
            self.notify(address, data)

        try:
            listeners = self.address_listeners[address]
        except KeyError:
            listeners = []

        for listener in listeners:
            listener(address, data)
72774
void newMessage(final byte[] message, final Session session) {
        callback.recive(serializer.deserialize(message), session);
    }
162434
public void getScheduledNotificationRecipients(ScheduledNotification notification, Collection<Recipient> result) {
        List<String> lst = broker.callRPCList("RGCWXQ SCHRECIP", null, notification.getIen());
        result.clear();

        for (String data : lst) {
            result.add(new Recipient(data));
        }
    }
1013722
def receive_notification(self, message):
    """"""
    msg_type = message["message_type"]

    if msg_type == "game_start_message":
      info = self.__parse_game_start_message(message)
      self.receive_game_start_message(info)

    elif msg_type == "round_start_message":
      round_count, hole, seats = self.__parse_round_start_message(message)
      self.receive_round_start_message(round_count, hole, seats)

    elif msg_type == "street_start_message":
      street, state = self.__parse_street_start_message(message)
      self.receive_street_start_message(street, state)

    elif msg_type == "game_update_message":
      new_action, round_state = self.__parse_game_update_message(message)
      self.receive_game_update_message(new_action, round_state)

    elif msg_type == "round_result_message":
      winners, hand_info, state = self.__parse_round_result_message(message)
      self.receive_round_result_message(winners, hand_info, state)
535998
protected void handshakeReceived(IoSession session,
			HandshakeMessage handshakeMessage) {
		log.debug("Received {}", handshakeMessage);
		this.receivedHandshake = handshakeMessage;
		Boolean handshakeCheck = this.checkHandshake();
		if (handshakeCheck == null) {
			return;
		}

		if (Boolean.FALSE.equals(handshakeCheck)) {
			log.warn("Handshakes did not match.");
			this._disconnect();
		}
		if (Boolean.TRUE.equals(handshakeCheck)) {
			SubscriptionMessage msg = this.generateGenericSubscriptionMessage();
			this.session.write(msg);
			this.connected = true;
		}
	}
927299
@Override
	public final boolean packetReceived(AbstractPacket packet)
    {
        if (packet.getType() == PacketType.NOTIFICATION)
        {
            final NotificationPacket notifPacket = (NotificationPacket)packet;
            final AbstractMessage prefetchedMessage = notifPacket.getMessage();
            
            boolean acceptedByConsumer = false;
                
    		AbstractSession session = lookupRegisteredSession(notifPacket.getSessionId());
            if (session != null)
            {                   
                RemoteMessageConsumer consumer = (RemoteMessageConsumer)session.lookupRegisteredConsumer(notifPacket.getConsumerId());
                if (consumer != null)		
                    acceptedByConsumer = consumer.addToPrefetchQueue(prefetchedMessage,notifPacket.isDonePrefetching());
                else
                	log.debug("#"+id+" No such consumer : #"+notifPacket.getSessionId()+":"+notifPacket.getConsumerId()); // Consumer was concurrently closed or not yet registered
            }
            else
            	log.debug("#"+id+" No such session : #"+notifPacket.getSessionId()); // Session was concurrently closed
            
            // If the consumer was already gone, we need to rollback the prefetched message on the server side
            if (!acceptedByConsumer)
                scheduleRollback(notifPacket.getSessionId(),
                		         notifPacket.getConsumerId(),
                		         prefetchedMessage);
            
            return true;
        }
        
        if (packet.getType() == PacketType.R_PING)
        	return true;
        
        // Standard response, route to target endpoint
        transportHub.routeResponse((AbstractResponsePacket)packet);
        
        return true;
    }
1312269
def notificationNch():
    """"""
    a = L2PseudoLength(l2pLength=0x01)
    b = TpPd(pd=0x6)
    c = MessageType(mesType=0x20)  # 00100000
    d = NtNRestOctets()
    packet = a / b / c / d
    return packet