diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-16 13:41:12 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-16 13:41:12 +0200 |
| commit | de8b2adbcc4a39c359f3dd30249ac4ee225d4b9c (patch) | |
| tree | ba51a86a850e24bb54637becc7834a38c51d2429 /internal/fsm | |
| parent | fec6ea1eba9cee325bbd9d82aa71b8ebf5ef90b0 (diff) | |
Refactor: Use an interface for the data in the FSM callback
Diffstat (limited to 'internal/fsm')
| -rw-r--r-- | internal/fsm/fsm.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index 84c39d5..3c51ce7 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -124,12 +124,12 @@ type FSM struct { // Info to be passed from the parent state Name string - StateCallback func(FSMStateID, FSMStateID, string) + StateCallback func(FSMStateID, FSMStateID, interface{}) Directory string Debug bool } -func (fsm *FSM) Init(name string, callback func(FSMStateID, FSMStateID, string), directory string, debug bool) { +func (fsm *FSM) Init(name string, callback func(FSMStateID, FSMStateID, interface{}), directory string, debug bool) { fsm.States = FSMStates{ DEREGISTERED: FSMState{Transitions: []FSMTransition{{NO_SERVER, "Client registers"}}}, NO_SERVER: FSMState{Transitions: []FSMTransition{{CHOSEN_SERVER, "User chooses a server"}, {SEARCH_SERVER, "The user is trying to choose a Server in the UI"}, {CONNECTED, "The user is already connected"}, {ASK_LOCATION, "Change the location in the main screen"}}}, @@ -191,7 +191,7 @@ func (fsm *FSM) GoBack() { fsm.GoTransition(fsm.States[fsm.Current].BackState) } -func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data string, background bool) bool { +func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data interface{}, background bool) bool { ok := fsm.HasTransition(newState) if ok { |
