messaging

by lowclouds
See Code Download Embed
This project contains three types of messaging needed for another project I'm working on. They all use the undocumented Snap 5 feature of directing messages to a particular sprite (which now seems to have a nice new block in Snap 6. All of the messages have a standard form as a list of message name, sender name, and optional data.
   
 The first type is Pub/Sub messaging, which allows a sprite to Subscribe, Unsubscribe and Publish messages. The publisher doesn't know who, if anyone, will receive the message.

The second type I'm calling a Protocol, or Leader/Follower (in past projects I called it Client/Server, but that's not quite it.) This protocol defines a set of messages and a leader sprite. Other sprites can Register to follow the protocol, When the leader posts a message, it goes to all the followers, but when a follower posts, the message only goes to the leader. The leader may also direct a message to one specific follower. The typical use case for this is controlling overall system state where the system is a collection of cooperating state machines.

Finally, the Timer sprite provides timers that will deliver a message to the sprite that created them and can also be cancelled.

Created May 10, 2020

Last updated May 10, 2020

Shared May 10, 2020