Reputation: 9331
I am making mulitplayer quiz like game. I have chosen to use spring state machines to model each individual instance of the game on the server using @EnableStateMachineFactory
. But, I need every instance of the state machine to have additional game data/state info, and to init that data on the state machine startup with some custom startup data (like player usernames for example). Is ExtendedState
intended for such stuff and if it is how to send custom initial extended state data when creating the state machine with factory?
Upvotes: 1
Views: 920
Reputation: 2646
Yes ExtendedState
is only way to store data within a machine itself. I've used it like that so it's ok.
Order to initialize ExtendedState
I'd use machine's initial action which is executed when initial state entry logic happens. In UML machine model it's purpose by definition is to init machine.
Upvotes: 1