@@ -23,7 +23,7 @@ type Engine struct {
2323 currentState * state.State
2424 stateMachine * statemachine.StateMachine
2525 queue chan * statemachine.Change
26- hooks [ ]chan HookOut
26+ hooks map [ string ]chan HookOut
2727 timeProvider timer.TimeProvider
2828 lastTimeUpdate time.Time
2929 gcState * GcState
@@ -40,7 +40,7 @@ func NewEngine(gameConfig config.Game) (e *Engine) {
4040 e .stateStore = store .NewStore (gameConfig .StateStoreFile )
4141 e .stateMachine = statemachine .NewStateMachine (gameConfig )
4242 e .queue = make (chan * statemachine.Change , 100 )
43- e .hooks = [ ]chan HookOut {}
43+ e .hooks = map [ string ]chan HookOut {}
4444 e .SetTimeProvider (func () time.Time { return time .Now () })
4545 e .gcState = new (GcState )
4646 e .gcState .TeamState = map [string ]* GcStateTeam {
@@ -241,10 +241,12 @@ func (e *Engine) processChange(change *statemachine.Change) {
241241 log .Println ("Could not add new state to store: " , err )
242242 }
243243 stateCopy := e .currentState .Clone ()
244- for _ , hook := range e .hooks {
244+ hookOut := HookOut {Change : entry .Change , State : stateCopy }
245+ for name , hook := range e .hooks {
245246 select {
246- case hook <- HookOut {Change : entry .Change , State : stateCopy }:
247- default :
247+ case hook <- hookOut :
248+ case <- time .After (1 * time .Second ):
249+ log .Printf ("Hook %v unresponsive! Failed to sent %v" , name , hookOut )
248250 }
249251 }
250252
0 commit comments