|
@@ -25,7 +25,7 @@ import (
|
|
|
type EventType uint64
|
|
type EventType uint64
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
- Ping = 1 << iota
|
|
|
|
|
|
|
+ Ping EventType = 1 << iota
|
|
|
Starting
|
|
Starting
|
|
|
StartupComplete
|
|
StartupComplete
|
|
|
DeviceDiscovered
|
|
DeviceDiscovered
|
|
@@ -39,7 +39,7 @@ const (
|
|
|
FolderRejected
|
|
FolderRejected
|
|
|
ConfigSaved
|
|
ConfigSaved
|
|
|
|
|
|
|
|
- AllEvents = ^EventType(0)
|
|
|
|
|
|
|
+ AllEvents = (1 << iota) - 1
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func (t EventType) String() string {
|
|
func (t EventType) String() string {
|
|
@@ -131,7 +131,7 @@ func (l *Logger) Log(t EventType, data interface{}) {
|
|
|
select {
|
|
select {
|
|
|
case s.events <- e:
|
|
case s.events <- e:
|
|
|
default:
|
|
default:
|
|
|
- //log.Println("Dropping event:", e)
|
|
|
|
|
|
|
+ // if s.events is not ready, drop the event
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -157,7 +157,7 @@ func (l *Logger) Subscribe(mask EventType) *Subscription {
|
|
|
func (l *Logger) Unsubscribe(s *Subscription) {
|
|
func (l *Logger) Unsubscribe(s *Subscription) {
|
|
|
l.mutex.Lock()
|
|
l.mutex.Lock()
|
|
|
if debug {
|
|
if debug {
|
|
|
- dl.Debugln("unsubsribe")
|
|
|
|
|
|
|
+ dl.Debugln("unsubscribe")
|
|
|
}
|
|
}
|
|
|
delete(l.subs, s.id)
|
|
delete(l.subs, s.id)
|
|
|
close(s.events)
|
|
close(s.events)
|