refactor: 重命名 connection -> session

This commit is contained in:
2024-08-26 14:41:57 +08:00
parent a6cc98a32b
commit 82d3f99404
7 changed files with 31 additions and 33 deletions

View File

@ -5,16 +5,16 @@ import (
"strings"
)
type Connection struct {
type Session struct {
Device *onvif.Device `json:"device"`
}
func New(xaddr string, username string, password string) (*Connection, error) {
func NewSession(xaddr string, username string, password string) (*Session, error) {
// 规范化连接地址
if !strings.Contains(xaddr, ":") {
xaddr += ":80"
}
dev, err := onvif.NewDevice(onvif.DeviceParams{
Xaddr: xaddr,
Username: username,
@ -25,5 +25,5 @@ func New(xaddr string, username string, password string) (*Connection, error) {
return nil, err
}
return &Connection{Device: dev}, nil
return &Session{Device: dev}, nil
}

View File

@ -2,7 +2,7 @@ package onvif
import "github.com/IOTechSystems/onvif/device"
func (c *Connection) GetDeviceInfo() (*device.GetDeviceInformationResponse, error) {
func (c *Session) GetDeviceInfo() (*device.GetDeviceInformationResponse, error) {
resp, err := c.Device.CallMethod(device.GetDeviceInformation{})
if err != nil {
return nil, err

View File

@ -5,7 +5,7 @@ import (
"github.com/IOTechSystems/onvif/xsd"
)
func (c *Connection) SubscribeEvents(
func (c *Session) SubscribeEvents(
consumerAddress event.AttributedURIType,
terminationTime xsd.String, // PT60S
) (*event.SubscribeResponse, error) {