[fsm] Accessing a state instance in a state machine?

I had a quick look at the documentation of the Boost FSM library as I need to implement a simple protocol handler for a network application. The protocol handler sends and receives text messages and switches between various states. What I wonder is how I can pass for example a reference to a socket to a state so that the state can send a text message? There doesn't seem to be a way to acccess a state instance in a state machine? Boris

Boris wrote:
I had a quick look at the documentation of the Boost FSM library as I need to implement a simple protocol handler for a network application. The protocol handler sends and receives text messages and switches between various states. What I wonder is how I can pass for example a reference to a socket to a state so that the state can send a text message? There doesn't seem to be a way to acccess a state instance in a state machine?
You can pass any data to the state machine in events. You can also access any state or its base class with a "get" method of the FSM. However, in your case I would consider keeping the socket inside the FSM in order to encapsulate all reaction specifics in the machine.
participants (2)
-
Andrey Semashev
-
Boris