feat(onvif): 添加通知存储

This commit is contained in:
2024-08-26 15:21:47 +08:00
parent ff5cc66a55
commit 0ef8af021f
4 changed files with 22 additions and 4 deletions

View File

@ -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)
}

View File

@ -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)
} }

View File

@ -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")

View File

@ -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