refactor
This commit is contained in:
parent
219116c961
commit
63fb12901b
@ -1,28 +1 @@
|
|||||||
package onvif
|
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)
|
|
||||||
}
|
|
||||||
|
@ -3,6 +3,7 @@ package onvif
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/IOTechSystems/onvif/event"
|
"github.com/IOTechSystems/onvif/event"
|
||||||
|
"github.com/IOTechSystems/onvif/gosoap"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -30,3 +31,21 @@ func CreateSubscription(c *gin.Context) {
|
|||||||
|
|
||||||
response.NewResponse().Success().WithData(result).Send(c)
|
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)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user