-
Feature Request
-
Resolution: Done
-
Major
-
None
-
None
Currently state transfer is not supported for ForkChannels: ForkChannel.getState() throws an exception.
State transfer could be implemented by catching events STATE_TRANSFER_OUTPUTSTREAM (get-state) and STATE_TRANSFER_INPUTSTREAM (set-state) in FORK.
When getState() is called (on the main or fork channel), the state provider gets a get-state in FORK. It then asks the main channel and all fork channels to write their states to the output stream, as follows:
| main-channel | state | fork-channel1 | state | fork-channel2 | state | ...
This is a list of {channel-name | state} pairs, where each state is prefixed with the name of the channel.
This can be implemented by simply passing the STATE_TRANSFER_OUTPUTSTREAM event up the main stack and each of its fork stacks.
On the state requester, the STATE_TRANSFER_INPUTSTREAM event is caught by FORK. Each {channel | state} pair is parsed for the channel name and then the input stream is passed to the corresponding channel for setState(InputStream) to be invoked.
This whole thing is designed as a one-shot state transfer, to be called once after the main channel and all fork-channels have been created. It is not meant to be called repeatedly (although this works).