31 lines
485 B
Go
31 lines
485 B
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package machine
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
ENTERSTATEEVENT = iota
|
|
EXITSTATEEVENT
|
|
)
|
|
|
|
type Eventtype int
|
|
|
|
type EventMessage struct {
|
|
On Eventtype
|
|
Source State
|
|
Dest State
|
|
}
|
|
|
|
type EventChannel chan EventMessage
|
|
|
|
func (e *EventChannel) Notify(m *EventMessage) {
|
|
*e <- *m
|
|
}
|
|
|
|
func (m EventMessage) String() string {
|
|
return fmt.Sprintf("{On: %d, Source: %s, Dest: %s}", m.On, m.Source, m.Dest)
|
|
}
|