Basic events interface

This commit is contained in:
Jakob Borg
2014-07-13 21:07:24 +02:00
parent c844991cba
commit b0f46beffb
7 changed files with 487 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ import (
"github.com/calmh/syncthing/config"
"github.com/calmh/syncthing/discover"
"github.com/calmh/syncthing/events"
"github.com/calmh/syncthing/logger"
"github.com/calmh/syncthing/model"
"github.com/calmh/syncthing/osutil"
@@ -454,10 +455,21 @@ nextRepo:
}()
}
events.Default.Log(events.StartupComplete, nil)
go generateEvents()
<-stop
l.Okln("Exiting")
}
func generateEvents() {
for {
time.Sleep(300 * time.Second)
events.Default.Log(events.Ping, nil)
}
}
func waitForParentExit() {
l.Infoln("Waiting for parent to exit...")
// Wait for the listen address to become free, indicating that the parent has exited.
@@ -723,6 +735,10 @@ next:
protoConn := protocol.NewConnection(remoteID, conn, wr, m)
l.Infof("Established secure connection to %s at %v", remoteID, conn.RemoteAddr())
events.Default.Log(events.NodeConnected, map[string]string{
"id": remoteID.String(),
"addr": conn.RemoteAddr().String(),
})
m.AddConnection(conn, protoConn)
continue next