lib/connections: Accept new connections in place of old ones (fixes #5224) (#6548)

This commit is contained in:
MikolajTwarog
2020-04-20 08:23:38 +02:00
committed by GitHub
parent 49798552f2
commit 4aa2199d5b
2 changed files with 11 additions and 6 deletions
+7 -3
View File
@@ -145,9 +145,10 @@ type Connection interface {
}
type rawConnection struct {
id DeviceID
name string
receiver Model
id DeviceID
name string
receiver Model
startTime time.Time
cr *countingReader
cw *countingWriter
@@ -236,6 +237,7 @@ func (c *rawConnection) Start() {
go c.writerLoop()
go c.pingSender()
go c.pingReceiver()
c.startTime = time.Now()
}
func (c *rawConnection) ID() DeviceID {
@@ -958,6 +960,7 @@ type Statistics struct {
At time.Time
InBytesTotal int64
OutBytesTotal int64
StartedAt time.Time
}
func (c *rawConnection) Statistics() Statistics {
@@ -965,6 +968,7 @@ func (c *rawConnection) Statistics() Statistics {
At: time.Now(),
InBytesTotal: c.cr.Tot(),
OutBytesTotal: c.cw.Tot(),
StartedAt: c.startTime,
}
}