This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2017-12-16 23:20:46 +01:00
|
|
|
package state
|
|
|
|
|
2018-02-07 15:34:18 +01:00
|
|
|
import "dev.sum7.eu/genofire/yaja/server/utils"
|
2017-12-16 23:20:46 +01:00
|
|
|
|
|
|
|
// State processes the stream and moves to the next state
|
|
|
|
type State interface {
|
2017-12-17 17:50:51 +01:00
|
|
|
Process() State
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start state
|
|
|
|
type Debug struct {
|
|
|
|
Next State
|
|
|
|
Client *utils.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process message
|
|
|
|
func (state *Debug) Process() State {
|
|
|
|
state.Client.Log = state.Client.Log.WithField("state", "debug")
|
|
|
|
state.Client.Log.Debug("running")
|
|
|
|
defer state.Client.Log.Debug("leave")
|
|
|
|
|
|
|
|
element, err := state.Client.Read()
|
|
|
|
if err != nil {
|
|
|
|
state.Client.Log.Warn("unable to read: ", err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
state.Client.Log.Info(element)
|
|
|
|
|
|
|
|
return state.Next
|
2017-12-16 23:20:46 +01:00
|
|
|
}
|