chore: 添加注册设备条目数
This commit is contained in:
parent
254b41e160
commit
b1ad068073
@ -1,28 +1,26 @@
|
||||
package zabbixagent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"onvif-agent/response"
|
||||
handler "onvif-agent/router/handler/onvif"
|
||||
service "onvif-agent/service/onvif"
|
||||
)
|
||||
|
||||
func DiscoverONVIFDevices(c *gin.Context) {
|
||||
type ZBXDevice struct {
|
||||
type device struct {
|
||||
Xaddr string `json:"{#XADDR}"`
|
||||
}
|
||||
|
||||
arr := make([]ZBXDevice, 0)
|
||||
devices := make([]device, 0)
|
||||
for xaddr := range service.Sessions {
|
||||
arr = append(arr, ZBXDevice{
|
||||
devices = append(devices, device{
|
||||
Xaddr: xaddr,
|
||||
})
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": arr,
|
||||
})
|
||||
response.NewResponse().WithData(devices).Send(c)
|
||||
}
|
||||
|
||||
func RegisterONVIFDevices(c *gin.Context) {
|
||||
@ -53,7 +51,7 @@ func RegisterONVIFDevices(c *gin.Context) {
|
||||
|
||||
service.Sessions = sessions
|
||||
|
||||
response.NewResponse().Success().Send(c)
|
||||
response.NewResponse().Success().WithMessage(fmt.Sprintf("%d device(s) registered", len(sessions))).Send(c)
|
||||
}
|
||||
|
||||
type ConsumeNotificationsRequest struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user