Skip to content

URSYS messaging future upgrades

Flynn Duniho edited this page May 30, 2024 · 1 revision

I spent a few hours trying to add CHANNEL support to our messaging scheme. The idea of channels is that when creating a subscribing message function or calling a message, we can specify whether it is LOCAL, NET, or BOTH. Simple enough, but the underlying infrastructure is actually quite attuned to NOT using channels. It instead uses three options that are added through URLINK to the underlying MESSAGER class:

  • toNet is set true by NetCall, NetSubscribe, and NetPublish
  • toLocal is set true by LocalCall, NetSubscribe, and NetPublish
  • fromNet is set only by m_HandleMessage() when receiving a packet from the network, which tells MESSAGER that it should call the local message handler defined for it appropriately.

I found it confusing to keep directions straight. The Net* and Local* calls are written from the client authoring perspective, and the three options are also named from that perspective. The tricky part is tagging the handler functions with channel information and inferring fromNet.

A big question is whether the channel is defined as part of the message, but this creates the case where you might do a NetSubscribe('NET:MESSAGE') and then the incoming message from a remote needs to invoke the message LOCALLY instead of reforwarding it to the net. The logic is a little convoluted and the testing code I have is too unreliable to help debug this cleanly, so I've punted on it until I get a chance to rewrite URSYS as a standalone test-driven-design library.