refactor: 迁移 service 代码逻辑
This commit is contained in:
@ -3,12 +3,12 @@ package onvif
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/IOTechSystems/onvif/event"
|
||||
"github.com/IOTechSystems/onvif/gosoap"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
"onvif-agent/config"
|
||||
"onvif-agent/response"
|
||||
"onvif-agent/service/onvif"
|
||||
)
|
||||
|
||||
func CreateSubscription(c *gin.Context) {
|
||||
@ -16,7 +16,7 @@ func CreateSubscription(c *gin.Context) {
|
||||
callbackURL := event.AttributedURIType(fmt.Sprintf("%s/onvif/subscriptions/%s/callback", config.Config.App.URL, xaddr))
|
||||
log.Printf("CreateSubscription callback URL: %s", callbackURL)
|
||||
|
||||
conn := Sessions[xaddr]
|
||||
conn := onvif.Sessions[xaddr]
|
||||
if conn == nil {
|
||||
response.NewResponse().Fail("Connection not found").WithCode(http.StatusNotFound).Send(c)
|
||||
return
|
||||
@ -30,21 +30,3 @@ 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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user