CRecordBroadcastSendMsg

This record is a nano service in the SYSTEM namespace. If you send another message to this nano service with this record, the service sends the message to all other nodes (in the same segment).

{
  "id": "bec781a3-0250-4bcc-9750-f33e0c3dd3ef",
  "name": "BROADCAST_SEND_MSG",
  "isService": "true",
  "namespaces": "SYSTEM",
  "description": "Send a broadcast message per flooding to other nodes.",
  "slots": [
    {
      "key": "2",
      "name": "LOCALLY",
      "direction": "REQUEST",
      "mandatory": "false",
      "type": "BOOLEAN",
      "description": "True if the message shall be send locally too (not only to other nodes)."
    },
    {
      "key": "1",
      "name": "MESSAGE",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "MESSAGE",
      "description": "The broadcast message."
    },
    {
      "key": "4",
      "name": "NEGATIVE_FILTER",
      "direction": "REQUEST",
      "mandatory": "false",
      "type": "NODE_ADDRESS_ARRAY",
      "description": "A negative filter. Neighbors that are in this list will NOT become the message. Optional."
    },
    {
      "key": "3",
      "name": "POSITIVE_FILTER",
      "direction": "REQUEST",
      "mandatory": "false",
      "type": "NODE_ADDRESS_ARRAY",
      "description": "A positive filter. Only neighbors that are in this list will become the message. Optional."
    }
  ]
}

Sending a broadcast message

A broadcast message is a message intended for a nano service (usually in the SYSTEM namespace) in all nodes simultaneously. A nano service in the plugin NY_Network is responsible for sending broadcasts. The desired message is simply sent to this local nano service, which then sends the broadcast to all nodes. The record sent must also be a nano service, so that all targets that have attached themselves to this nano service as observers receive a copy of the message.

void broadCast(@NotNull final CEnvelope aEnvelope,
               @NotNull final CRecord aRecord) throws CException
{
    aEnvelope.setSender(getAddress());
    final CMessage msgToSend = new CMessage(aEnvelope,
                                            aRecord);

    final CEnvelope env = CEnvelope.forLocalNanoService(CWellKnownNID.SYSTEM);
    final CRecord rec = CRecordBroadcastSendMsg.create();
    CRecordBroadcastSendMsg.setLocally(rec,
                                       true);
    CRecordBroadcastSendMsg.setMessage(rec,
                                       msgToSend);
    send(env,
         rec);
}

nyssr.net - Innovative Distributed System