macula_chatter (macula v0.20.5)

View Source

Macula Chatter - P2P PubSub Demo for NAT Traversal Testing

A pub/sub chat application that demonstrates broadcast messaging across NAT boundaries using Macula's pub/sub capabilities.

Each chatter node: - Subscribes to "chat.room.global" topic - Periodically broadcasts numbered messages to all peers - Tracks delivery metrics per peer (by NAT type) - Reports delivery rates at shutdown

PubSub Delivery Metrics: - Each broadcast includes a sequence number - Receivers track which sequence numbers they've seen per sender - Gaps in sequence numbers indicate missed messages - Delivery rate = received / expected (based on max seq seen)

Summary

Functions

Get statistics about messages sent/received

Send a direct message to a specific peer via RPC

Send a message to all peers via pubsub

Start the chatter with default settings

Start the chatter with options Options: - interval: milliseconds between broadcasts (default: 5000) - node_id: custom node identifier (default: hostname)

Functions

get_stats()

-spec get_stats() -> map().

Get statistics about messages sent/received

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(Opts)

send_direct(PeerId, Message)

-spec send_direct(binary(), binary()) -> ok | {error, term()}.

Send a direct message to a specific peer via RPC

send_message(Message)

-spec send_message(binary()) -> ok.

Send a message to all peers via pubsub

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

Start the chatter with default settings

start_link(Opts)

-spec start_link(map()) -> {ok, pid()} | {error, term()}.

Start the chatter with options Options: - interval: milliseconds between broadcasts (default: 5000) - node_id: custom node identifier (default: hostname)

terminate(Reason, State)