Skip to content

Commit

Permalink
Update Subscribe message
Browse files Browse the repository at this point in the history
  • Loading branch information
Phuocpr1998 committed Nov 23, 2020
1 parent 9a652c4 commit 4306402
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
16 changes: 10 additions & 6 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ func (device Device) Subscribe(address string) (string, error) {
soap := SOAP{
User: device.User,
Password: device.Password,
Body: `<Subscribe xmlns="http://docs.oasis-open.org/wsn/b-2">
<ConsumerReference>
<Address>` + address + `</Address>
</ConsumerReference>
<InitialTerminationTime>PT3600S</InitialTerminationTime>
</Subscribe>`,
XMLNs: []string{
`xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"`,
`xmlns:wsa="http://www.w3.org/2005/08/addressing"`,
},
Body: `<wsnt:Subscribe xmlns="http://docs.oasis-open.org/wsn/b-2.xsd">
<wsnt:ConsumerReference>
<wsa:Address xmlns="http://www.w3.org/2005/08/addressing">` + address + `</wsa:Address>
</wsnt:ConsumerReference>
<wsnt:InitialTerminationTime>PT3600S</wsnt:InitialTerminationTime>
</wsnt:Subscribe>`,
}

var result string = ""
Expand Down
26 changes: 26 additions & 0 deletions media.go
Original file line number Diff line number Diff line change
Expand Up @@ -1632,3 +1632,29 @@ func (device Device) GetAudioEncoderConfigurationOptions(configurationToken stri
glog.Info(result)
return result, nil
}

func (device Device) GetOSDs() ([]AudioEncoderConfigurationOption, error) {
// create soap
soap := SOAP{
User: device.User,
Password: device.Password,
Body: `<GetOSDs xmlns="http://www.onvif.org/ver10/media/wsdl" />`,
}

result := []AudioEncoderConfigurationOption{}

// send request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return result, err
}

// parse response
ifOSDsResponse, err := response.ValuesForPath("Envelope.Body.GetOSDsResponse")
if err != nil {
return result, err
}

glog.Info("Data %s", ifOSDsResponse)
return result, nil
}

0 comments on commit 4306402

Please sign in to comment.