feat(onvif): 添加通知存储
This commit is contained in:
@ -1 +1,11 @@
|
|||||||
package onvif
|
package onvif
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"onvif-agent/response"
|
||||||
|
"onvif-agent/service/onvif"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetNotifications(c *gin.Context) {
|
||||||
|
response.NewResponse().WithData(onvif.Notifications).Send(c)
|
||||||
|
}
|
||||||
|
@ -43,10 +43,11 @@ func NotifyCallback(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle notifications
|
onvif.Notifications[xaddr] = append(onvif.Notifications[xaddr], notify.NotificationMessage...)
|
||||||
for _, msg := range envelope.Body.Content.(*event.Notify).NotificationMessage {
|
|
||||||
log.Printf("Topic: %s, Message: %s", msg.Topic.TopicKinds, msg.Message.Message)
|
//for _, msg := range envelope.Body.Content.(*event.Notify).NotificationMessage {
|
||||||
}
|
// log.Printf("Topic: %s, Message: %s", msg.Topic.TopicKinds, msg.Message.Message)
|
||||||
|
//}
|
||||||
|
|
||||||
response.NewResponse().Success().Send(c)
|
response.NewResponse().Success().Send(c)
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,11 @@ func SetupRoutes(r *gin.Engine) {
|
|||||||
subscriptionGroup.POST("/:xaddr", onvif.CreateSubscription)
|
subscriptionGroup.POST("/:xaddr", onvif.CreateSubscription)
|
||||||
subscriptionGroup.POST("/:xaddr/callback", onvif.NotifyCallback)
|
subscriptionGroup.POST("/:xaddr/callback", onvif.NotifyCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notificationGroup := onvifGroup.Group("/notifications")
|
||||||
|
{
|
||||||
|
notificationGroup.GET("/", onvif.GetNotifications)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zabbixGroup := r.Group("/zabbix")
|
zabbixGroup := r.Group("/zabbix")
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"github.com/IOTechSystems/onvif/xsd"
|
"github.com/IOTechSystems/onvif/xsd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Notifications = make(map[string][]event.NotificationMessage)
|
||||||
|
|
||||||
func (c *Session) EventSubscribe(
|
func (c *Session) EventSubscribe(
|
||||||
consumerAddress event.AttributedURIType,
|
consumerAddress event.AttributedURIType,
|
||||||
terminationTime xsd.String, // PT60S
|
terminationTime xsd.String, // PT60S
|
||||||
|
Reference in New Issue
Block a user