mirror of
https://github.com/lkmio/gb-cms.git
synced 2025-09-26 19:51:22 +08:00
修改移动位置订阅问题
This commit is contained in:
@@ -154,7 +154,7 @@ func (d *Device) SubscribePosition(channelId string) error {
|
||||
|
||||
//暂时不考虑级联
|
||||
builder := d.NewRequestBuilder(sip.SUBSCRIBE, Config.SipID, Config.SipContactAddr, channelId)
|
||||
body := fmt.Sprintf(MobilePositionMessageFormat, "1", channelId, Config.MobilePositionInterval)
|
||||
body := fmt.Sprintf(MobilePositionMessageFormat, 1, channelId, Config.MobilePositionInterval)
|
||||
|
||||
expiresHeader := sip.Expires(Config.MobilePositionExpires)
|
||||
builder.SetExpires(&expiresHeader)
|
||||
@@ -167,7 +167,7 @@ func (d *Device) SubscribePosition(channelId string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
event := Event("Catalog;id=2")
|
||||
event := Event(EventPresence)
|
||||
request.AppendHeader(&event)
|
||||
response, err := SipStack.SendRequestWithTimeout(5, request)
|
||||
if err != nil {
|
||||
|
22
position.go
22
position.go
@@ -5,13 +5,17 @@ import (
|
||||
"github.com/ghettovoice/gosip/sip"
|
||||
)
|
||||
|
||||
const MobilePositionMessageFormat = "<?xml version=\"1.0\"?>\r\n" +
|
||||
"<Query>\r\n" +
|
||||
"<CmdType>MobilePosition</CmdType>\r\n" +
|
||||
"<SN>%s</SN>\r\n" +
|
||||
"<DeviceID>%s</DeviceID>\r\n" +
|
||||
"<Interval>%d</Interval>\r\n" +
|
||||
"</Query>\r\n"
|
||||
const (
|
||||
EventPresence = "presence" //SIP 的事件通知机制(如 RFC 3856 和 RFC 6665)实现
|
||||
//MobilePositionMessageFormat = "<?xml version=\"1.0\"?>\r\n" +
|
||||
// "<Query>\r\n" +
|
||||
// "<CmdType>MobilePosition</CmdType>\r\n" +
|
||||
// "<SN>%s</SN>\r\n" +
|
||||
// "<DeviceID>%s</DeviceID>\r\n" +
|
||||
// "<Interval>%d</Interval>\r\n" +
|
||||
// "</Query>\r\n"
|
||||
MobilePositionMessageFormat = "<Query><CmdType>MobilePosition</CmdType><SN>%d</SN><DeviceID>%s</DeviceID><Interval>%d</Interval></Query>"
|
||||
)
|
||||
|
||||
type MobilePositionNotify struct {
|
||||
DeviceID string `xml:"DeviceID"`
|
||||
@@ -32,7 +36,7 @@ func (d *Device) DoSubscribePosition(channelId string) error {
|
||||
|
||||
//暂时不考虑级联
|
||||
builder := d.NewRequestBuilder(sip.SUBSCRIBE, Config.SipID, Config.SipContactAddr, channelId)
|
||||
body := fmt.Sprintf(MobilePositionMessageFormat, "1", channelId, Config.MobilePositionInterval)
|
||||
body := fmt.Sprintf(MobilePositionMessageFormat, 1, channelId, Config.MobilePositionInterval)
|
||||
|
||||
expiresHeader := sip.Expires(Config.MobilePositionExpires)
|
||||
builder.SetExpires(&expiresHeader)
|
||||
@@ -45,7 +49,7 @@ func (d *Device) DoSubscribePosition(channelId string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
event := Event("Catalog;id=2")
|
||||
event := Event(EventPresence)
|
||||
request.AppendHeader(&event)
|
||||
response, err := SipStack.SendRequestWithTimeout(5, request)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user