diff --git a/router/handler/onvif/notification.go b/router/handler/onvif/notification.go index d16472d..b6b13c5 100644 --- a/router/handler/onvif/notification.go +++ b/router/handler/onvif/notification.go @@ -1,28 +1 @@ package onvif - -import ( - "github.com/IOTechSystems/onvif/event" - "github.com/IOTechSystems/onvif/gosoap" - "github.com/gin-gonic/gin" - "log" - "net/http" - "onvif-agent/response" -) - -func NotifyCallback(c *gin.Context) { - //xaddr := c.Param("xaddr") - - var notify event.Notify - envelope := gosoap.NewSOAPEnvelope(¬ify) - if err := c.ShouldBindXML(&envelope); err != nil { - response.NewResponse().Error(err).WithCode(http.StatusBadRequest).Send(c) - return - } - - // TODO: handle notifications - 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) -} diff --git a/router/handler/onvif/subscription.go b/router/handler/onvif/subscription.go index e36d6d7..1bf7bbb 100644 --- a/router/handler/onvif/subscription.go +++ b/router/handler/onvif/subscription.go @@ -3,6 +3,7 @@ package onvif import ( "fmt" "github.com/IOTechSystems/onvif/event" + "github.com/IOTechSystems/onvif/gosoap" "github.com/gin-gonic/gin" "log" "net/http" @@ -30,3 +31,21 @@ func CreateSubscription(c *gin.Context) { response.NewResponse().Success().WithData(result).Send(c) } + +func NotifyCallback(c *gin.Context) { + //xaddr := c.Param("xaddr") + + var notify event.Notify + envelope := gosoap.NewSOAPEnvelope(¬ify) + if err := c.ShouldBindXML(&envelope); err != nil { + response.NewResponse().Error(err).WithCode(http.StatusBadRequest).Send(c) + return + } + + // TODO: handle notifications + 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) +}