mirror of
https://github.com/Monibuca/plugin-gb28181.git
synced 2025-12-24 13:27:57 +08:00
更新device时关闭定时器
This commit is contained in:
@@ -51,6 +51,7 @@ type Device struct {
|
||||
CallID string
|
||||
Timeout time.Time
|
||||
}
|
||||
qTimer *time.Timer
|
||||
}
|
||||
|
||||
func (d *Device) addChannel(channel *Channel) {
|
||||
@@ -190,7 +191,7 @@ func (d *Device) Query() {
|
||||
}
|
||||
if response.Code != 200 {
|
||||
fmt.Printf("device %s send Catalog : %d\n", d.ID, response.Code)
|
||||
time.AfterFunc(time.Second*5, d.Query)
|
||||
d.qTimer = time.AfterFunc(time.Second*5, d.Query)
|
||||
} else {
|
||||
d.Subscribe()
|
||||
}
|
||||
|
||||
4
main.go
4
main.go
@@ -352,11 +352,15 @@ func listenMedia() {
|
||||
func onRegister(s *transaction.Core, config *transaction.Config, d *Device) {
|
||||
if old, ok := Devices.Load(d.ID); ok {
|
||||
oldD := old.(*Device)
|
||||
if oldD.qTimer != nil {
|
||||
oldD.qTimer.Stop()
|
||||
}
|
||||
d.RegisterTime = oldD.RegisterTime
|
||||
d.channelMap = oldD.channelMap
|
||||
d.Channels = oldD.Channels
|
||||
d.UpdateChannelsDevice()
|
||||
d.Status = oldD.Status
|
||||
go d.Query()
|
||||
}
|
||||
Devices.Store(d.ID, d)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user