-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy patheventsService.go
79 lines (68 loc) · 3.66 KB
/
eventsService.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package onvif4go
import (
tev "github.com/faceterteam/onvif4go/events"
)
type EventsService struct {
Client onvifCaller
endpoint string
}
func NewEventsService(endpoint string, onvifDevice *OnvifDevice) *EventsService {
return &EventsService{
Client: NewOnvifClient(endpoint, &onvifDevice.auth),
endpoint: endpoint,
}
}
func (s *EventsService) makeAddressingHeaders(action string) []interface{} {
return tev.MakeAnonymousAddressingHeaders(action, s.endpoint)
}
// GetServiceCapabilities returns the capabilities of the event service.
func (s *EventsService) GetServiceCapabilities() (res tev.GetServiceCapabilitiesResponse, err error) {
headers := s.makeAddressingHeaders("http://www.onvif.org/ver10/events/wsdl/EventPortType/GetServiceCapabilitiesRequest")
err = s.Client.Call(tev.GetServiceCapabilities{}, &res, headers...)
return
}
/*
GetEventProperties returns information about the FilterDialects, Schema files and
topics supported by the device.
The WS-BaseNotification specification defines a set of OPTIONAL WS-ResouceProperties.
This specification does not require the implementation of the WS-ResourceProperty interface.
Instead, the subsequent direct interface shall be implemented by an ONVIF compliant device
in order to provide information about the FilterDialects, Schema files and topics supported by
the device.
*/
func (s *EventsService) GetEventProperties() (res tev.GetEventPropertiesResponse, err error) {
headers := s.makeAddressingHeaders("http://www.onvif.org/ver10/events/wsdl/EventPortType/GetEventPropertiesRequest")
err = s.Client.Call(tev.GetEventProperties{}, &res, headers...)
return
}
/*
CreatePullPointSubscription returns a PullPointSubscription that can be polled using PullMessages.
This message contains the same elements as the SubscriptionRequest of the WS-BaseNotification
without the ConsumerReference.
If no Filter is specified the pullpoint notifies all occurring events to the client.
*/
func (s *EventsService) CreatePullPointSubscription(filter string, changeOnly bool, initialTerminationTime *tev.AbsoluteOrRelativeTimeType) (res tev.CreatePullPointSubscriptionResponse, err error) {
headers := s.makeAddressingHeaders("http://www.onvif.org/ver10/events/wsdl/EventPortType/CreatePullPointSubscriptionRequest")
err = s.Client.Call(tev.CreatePullPointSubscription{
Filter: tev.FilterType(filter),
SubscriptionPolicy: &tev.SubscriptionPolicy{
ChangedOnly: changeOnly,
},
InitialTerminationTime: initialTerminationTime,
}, &res, headers...)
/*
<wsdl:fault name="ResourceUnknownFault" message="wsrf-rw:ResourceUnknownFault"/>
<wsdl:fault name="InvalidFilterFault" message="wsntw:InvalidFilterFault"/>
<wsdl:fault name="TopicExpressionDialectUnknownFault" message="wsntw:TopicExpressionDialectUnknownFault"/>
<wsdl:fault name="InvalidTopicExpressionFault" message="wsntw:InvalidTopicExpressionFault"/>
<wsdl:fault name="TopicNotSupportedFault" message="wsntw:TopicNotSupportedFault"/>
<wsdl:fault name="InvalidProducerPropertiesExpressionFault" message="wsntw:InvalidProducerPropertiesExpressionFault"/>
<wsdl:fault name="InvalidMessageContentExpressionFault" message="wsntw:InvalidMessageContentExpressionFault"/>
<wsdl:fault name="UnacceptableInitialTerminationTimeFault" message="wsntw:UnacceptableInitialTerminationTimeFault"/>
<wsdl:fault name="UnrecognizedPolicyRequestFault" message="wsntw:UnrecognizedPolicyRequestFault"/>
<wsdl:fault name="UnsupportedPolicyRequestFault" message="wsntw:UnsupportedPolicyRequestFault"/>
<wsdl:fault name="NotifyMessageNotSupportedFault" message="wsntw:NotifyMessageNotSupportedFault"/>
<wsdl:fault name="SubscribeCreationFailedFault" message="wsntw:SubscribeCreationFailedFault"/>
*/
return
}