/// <summary> /// This method is called by the process manager to process a request. /// </summary> public void ProcessRequest() { // Performance debuging DebugTiming timeDebuger = new DebugTiming(); timeDebuger.ResetStartTime("***Request Debug timer started"); // Process the message byte[] soapResponse = ProcessRequestMessage(); // If response is null the requested service is not implemented so just ignore this request if (soapResponse == null) { return; } // Performance debuging timeDebuger.PrintElapsedTime("***ProcessMessage Took"); // Send the response WsUdpServiceHost.SendMessage(m_remoteEP, soapResponse); // Performance Debuging timeDebuger.PrintElapsedTime("***Send Message Took"); System.Ext.Console.Write("Response To: " + m_remoteEP.ToString()); System.Ext.Console.Write(new String(System.Text.Encoding.UTF8.GetChars(soapResponse))); return; }
/// <summary> /// Stop tranport services and releases the managed resources used by this class. /// </summary> /// <param name="disposing">True to release managed resources</param> internal void Dispose(bool disposing) { if (disposing) { // Stop the transport services m_httpServiceHost.Stop(); m_udpSeviceHost.Stop(); m_threadLock = null; m_discoClient = null; m_endpointAddress = null; m_eventClient = null; m_mexClient = null; m_eventCallbacks = null; m_transportAddress = null; m_bodyParts = null; m_discoServiceEndpoints = null; m_callbackServiceEndpoints = null; m_udpSeviceHost = null; m_httpServiceHost = null; } }
private void Init() { m_discoClient = new DpwsDiscoveryClient(this); // Set the initial endpoint address m_endpointAddress = "urn:uuid:" + Guid.NewGuid(); // Add the Hello and Bye discovery disco services ClientDiscoveryService = new DpwsDiscoClientService(this); m_discoServiceEndpoints.Add(ClientDiscoveryService); // Start a Udp discovery service host m_udpSeviceHost = new WsUdpServiceHost(m_discoServiceEndpoints); if (!m_udpSeviceHost.IsRunning) { m_udpSeviceHost.IgnoreRequestFromThisIP = m_ignoreRequestFromThisIP; m_udpSeviceHost.MaxThreadCount = 5; m_udpSeviceHost.Start(); System.Ext.Console.Write("Udp service host started..."); } else m_udpSeviceHost = null; // Add eventing SubscriptionEnd ServiceOperations. By default Subscription End call back // to this client ServiceOperations.Add(new WsServiceOperation(WsWellKnownUri.WseNamespaceUri, "SubscriptionEnd")); // Add callbacks implemented by this client m_callbackServiceEndpoints.Add(this); // Start the Http service host m_httpServiceHost = new WsHttpServiceHost(m_port, m_callbackServiceEndpoints); m_httpServiceHost.MaxThreadCount = m_callbackServiceEndpoints.Count; m_httpServiceHost.Start(); System.Ext.Console.Write("Http service host started..."); }
/// <summary> /// Initializes the device. This method builds the colletion of internal device services, sets /// the devices transport address and adds DPWS required namespaces to the devices namespace collection. /// </summary> private static void Init() { // Add disco services to udp service endpoints collection m_discoveryService = new DpwsDeviceDiscoService(); m_discoServiceEndpoints.Add(m_discoveryService); // Create a new udp service host and add the discovery endpoints m_udpServiceHost = new WsUdpServiceHost(m_discoServiceEndpoints); m_udpServiceHost.IgnoreRequestFromThisIP = m_ignoreRequestFromThisIP; // Add metadata get service endpoint m_discoMexService = new DpwsDeviceMexService(); m_hostedServices.Add(m_discoMexService); // Add directd probe service endpoint m_hostedServices.Add(m_discoveryService); // Create a new http service host and add hosted services endpoints m_httpServiceHost = new WsHttpServiceHost(m_port, m_hostedServices); // Set the device endpoint address if (m_transportAddress == null) { m_transportAddress = "http://" + IPV4Address + ":" + m_port + "/" + m_address.Substring(9); System.Ext.Console.Write(""); System.Ext.Console.Write("IP Address: " + IPV4Address); System.Ext.Console.Write(""); } }