pub-NSDNC
The pub-<MsgEnv> for macOS. The ME is NSDistributedNotificationCenter, the publish/subscribe that macOS already provides between the processes of a user session.
Repository |
|
|---|---|
Wrapper library |
USAGE: pub-NSDNC <0|1> <string>
What it does
-
Generates a UUID for this run.
-
Subscribes to the ME.
-
Publishes
<string>, with the UUID as the notification’s object. -
Runs the run loop in slices of one second. With
1it loops until stopped with ^C; with0it runs one slice and exits.
Every message heard is logged through NSLog as pub ← nsdnc — […]. The tool’s own message comes back too; it is recognised by the UUID in the notification’s object and dropped without a line. This is the "referer" clause from the IPSME conventions in its simplest form.
On the wire
Notification name |
|
|---|---|
Payload |
|
Object |
the publisher’s UUID string |
All participants on this ME share the one notification name; IPSME does not divide an ME into channels. The payload travels in userInfo because macOS no longer accepts nil as a name filter when observing.
Apple forbids sandboxed apps from sending userInfo in distributed notifications. pub-NSDNC is not sandboxed. A participant that is sandboxed cannot publish on this ME and needs another one, such as a WebSocket or MQTT over the network.
|
Source and build
The repository is an Xcode project; the tool is pub-NSDNC/main.m. The wrapper library objc-msgenv-NSDNC comes in as a git submodule and provides IPSME_MsgEnv (subscribe:, publish:withObject:).
make xcode # xcodebuild, Release, arm64, into _DerivedData
make dist # bin/pub-NSDNC, Info.plist, dist/pub-NSDNC@<version>.tar.gz and its .sha384
The version comes from CFBundleShortVersionString in pub-NSDNC/Info.plist; package.json carries the same number.
make dist is what feeds the npm package @ioi-ri/pub-nsdnc, for darwin only. Info.plist declares it an IOI_CommandLineBinary, so it is a command and not an agent: nothing is loaded into launchd.