private async Task <EndpointAddress> GetSubscriptionEndPointAddress(Uri eventServiceUri) { var portTypeClient = _onvifClientFactory.CreateClient <EventPortType>(eventServiceUri, _connectionParameters, MessageVersion.Soap12WSAddressing10); string terminationTime = GetTerminationTime(); var subscriptionRequest = new CreatePullPointSubscriptionRequest(null, terminationTime, null, null); CreatePullPointSubscriptionResponse response = await portTypeClient.CreatePullPointSubscriptionAsync(subscriptionRequest); var subscriptionRefUri = new Uri(response.SubscriptionReference.Address.Value); var adressHeaders = new List <AddressHeader>(); if (response.SubscriptionReference.ReferenceParameters?.Any != null) { foreach (System.Xml.XmlElement element in response.SubscriptionReference.ReferenceParameters.Any) { adressHeaders.Add(new CustomAddressHeader(element)); } } var seviceUri = GetServiceUri(subscriptionRefUri.PathAndQuery); var endPointAddress = new EndpointAddress(seviceUri, adressHeaders.ToArray()); return(endPointAddress); }
public OnVif1Events(OnVifDevice onVifDevice) : base(onVifDevice) { // m_ErrorMessage = ""; m_PullPointResponse = null; // m_onVifDevice = onVifDevice; m_EventPropertiesResponse = null; m_EventPortTypeClient = null; m_PullPointSubscriptionClient = null; m_SubscriptionManagerClient = null; // m_initialised = false; m_subscriptionTerminationTime = TimeSpan.FromSeconds(20); }
private EventPortType CreatEeventPortTypeFake() { var endPointRefType = new EndpointReferenceType { Address = new AttributedURIType { Value = "http://127.0.0.1" } }; var response = new CreatePullPointSubscriptionResponse(endPointRefType, new System.DateTime(), null, null); var eventPortTypeMock = new Mock <EventPortType>(); eventPortTypeMock.Setup( x => x.CreatePullPointSubscriptionAsync(It.IsNotNull <CreatePullPointSubscriptionRequest>())). Returns(Task.FromResult(response)); return(eventPortTypeMock.Object); }