Checkpoint
This commit is contained in:
125 files changed
+59376
No files matched your search
@@ -0,0 +1,56 @@
|
||||
package bragi
|
||||
|
||||
import "time"
|
||||
|
||||
type Event interface {
|
||||
// Source returns the source of the event.
|
||||
Source() Source
|
||||
|
||||
// Time of the event.
|
||||
Time() time.Time
|
||||
}
|
||||
|
||||
type (
|
||||
baseEvent struct {
|
||||
at time.Time
|
||||
source Source
|
||||
}
|
||||
|
||||
ConnectedEvent struct {
|
||||
baseEvent
|
||||
}
|
||||
|
||||
DisconnectedEvent struct {
|
||||
baseEvent
|
||||
Err error
|
||||
}
|
||||
|
||||
StatusEvent struct {
|
||||
baseEvent
|
||||
Status *Status
|
||||
}
|
||||
|
||||
TrackEvent struct {
|
||||
baseEvent
|
||||
Track *Track
|
||||
}
|
||||
)
|
||||
|
||||
func (e *baseEvent) Source() Source { return e.source }
|
||||
func (e *baseEvent) Time() time.Time { return e.at }
|
||||
|
||||
func NewConnectedEvent(s Source) *ConnectedEvent {
|
||||
return &ConnectedEvent{baseEvent{time.Now(), s}}
|
||||
}
|
||||
|
||||
func NewDisconnectedEvent(s Source, err error) *DisconnectedEvent {
|
||||
return &DisconnectedEvent{baseEvent{time.Now(), s}, err}
|
||||
}
|
||||
|
||||
func NewStatusEvent(s Source, v *Status) *StatusEvent {
|
||||
return &StatusEvent{baseEvent{time.Now(), s}, v}
|
||||
}
|
||||
|
||||
func NewTrackEvent(s Source, t *Track) *TrackEvent {
|
||||
return &TrackEvent{baseEvent{time.Now(), s}, t}
|
||||
}
|
||||
Reference in new issue
Block a user