29 lines
700 B
Go
29 lines
700 B
Go
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)
|
|
}
|