machine/message.go

31 lines
485 B
Go
Raw Normal View History

2024-04-04 17:33:22 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
2024-04-04 20:08:50 +00:00
2024-04-04 17:33:22 +00:00
package machine
import (
2024-04-04 20:08:50 +00:00
"fmt"
2024-04-04 17:33:22 +00:00
)
const (
2024-04-04 20:08:50 +00:00
ENTERSTATEEVENT = iota
EXITSTATEEVENT
2024-04-04 17:33:22 +00:00
)
type Eventtype int
type EventMessage struct {
2024-05-07 05:41:29 +00:00
On Eventtype
Source State
Dest State
2024-04-04 17:33:22 +00:00
}
type EventChannel chan EventMessage
func (e *EventChannel) Notify(m *EventMessage) {
2024-04-04 20:08:50 +00:00
*e <- *m
2024-04-04 17:33:22 +00:00
}
func (m EventMessage) String() string {
2024-05-07 05:41:29 +00:00
return fmt.Sprintf("{On: %d, Source: %s, Dest: %s}", m.On, m.Source, m.Dest)
2024-04-04 17:33:22 +00:00
}