This library contains the wrapper code for sending messages to a web messaging environment (ME). As per the IPSME specification a reflector is required to reflect messages from this ME to other MEs e.g., the ME of the operating system.
function ipsme_handler_(msg) {
console.log('ipsme_handler_: msg: ', msg);
try {
// add handlers ...
}
catch(e) {
// ...
}
console.log("ipsme_handler_: DROP! msg: ", msg);
}
IPSME_MsgEnv.subscribe(ipsme_handler_);
It is by design that a participant receives the messages it has published itself. If this is not desirable, each message can contain a "referer" (sic) identifier and a clause added in the ipsme_handler_
to drop those messages containing the participant's own referer id.
IPSME_MsgEnv.publish( ... );
The ME utilized, as so mentioned in the name, is broadcast channel. This "library" is entirely optional. IPSME dictates the use of a readily available pubsub. That means the code is roughly equal to the following:
const bc= new BroadcastChannel('IPSME');
bc.onmessage= function(event) {
const msg= event.data;
// add handlers here ...
}
I have chosen to use the 'IPSME' channel name although the IPSME specification doesn't divide communication into different channels; all IPSME participants receive all messages. Each channel is equal to a different ME with respect to the IPSME conventions.
bc.postMessage(msg);