From b3dddce77023fd1d0e5c7451cad97bb88264aa23 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Thu, 22 Aug 2024 13:33:19 +0200 Subject: FSM: Re-ordering and cleanup constructor --- client/client.go | 2 +- client/fsm.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'client') diff --git a/client/client.go b/client/client.go index a64b4a4..e5a39c0 100644 --- a/client/client.go +++ b/client/client.go @@ -145,7 +145,7 @@ func New(name string, version string, directory string, stateCallback func(FSMSt http.RegisterAgent(userAgentName(name), version) // Initialize the FSM - c.FSM = newFSM(stateCallback, directory) + c.FSM = newFSM(stateCallback) // Debug only if given c.Debug = debug diff --git a/client/fsm.go b/client/fsm.go index 3c2ed80..c8858f9 100644 --- a/client/fsm.go +++ b/client/fsm.go @@ -91,7 +91,6 @@ func GetStateName(s FSMStateID) string { func newFSM( callback func(FSMStateID, FSMStateID, interface{}) bool, - directory string, ) fsm.FSM { states := FSMStates{ StateDeregistered: FSMState{ @@ -168,9 +167,8 @@ func newFSM( }, }, } - returnedFSM := fsm.FSM{} - returnedFSM.Init(StateMain, states, callback, directory, GetStateName) - return returnedFSM + + return fsm.NewFSM(StateMain, states, callback, GetStateName) } // SetState sets the state for the client FSM to `state` -- cgit v1.2.3