static void OnStart(string[] args) { try { init = new Thread(o => { ChannelFactory <IPubSubEventAPI> factory = new ChannelFactory <IPubSubEventAPI>("IPubSubEventAPI"); IPubSubEventAPI client = factory.CreateChannel(); var r = new ReciverEndpointInfo { Address = new Uri(ConfigurationSettings.AppSettings["service_address"]), Binding = "KAKA" }; client.SubscribeForEvent("PSC", r); factory.Close(); reciver = new EventReciverService(); reciver.EventRecibed = OnRecive; ServiceHost h = new ServiceHost(reciver); h.Open(); }); init.Start(); } catch (Exception exc) { } }
static void Main(string[] args) { detected = new BindingList <EventData[]>(); EventReciverService reciver = new EventReciverService(); ServiceHost host = new ServiceHost(reciver); reciver.EventRecibed = AlarmEventHandler; host.Open(); SubscribeForEvent(); Console.WriteLine("Press Enter to Exit"); Console.ReadKey(); }
public static void Main() { ls = new List <SensorGroupCtrl>(); SomeClass A = new SomeClass(5); EventReciverService instance = new EventReciverService(); instance.EventRecibed = A.SomeMethod; ServiceHost r_host = new ServiceHost(instance); r_host.Open(); BuildDevicesControls(); ChannelFactory <IPubSubEventAPI> factory = new ChannelFactory <IPubSubEventAPI>("IPubSubEventAPI"); IPubSubEventAPI client = factory.CreateChannel(); InitSensors(); client.SubscribeForEvent("NSTAT", new ReciverEndpointInfo { Address = new Uri(ConfigurationManager.AppSettings["service_address"]), Binding = "KAKA" }); client.SubscribeForEvent("DTMF", new ReciverEndpointInfo { Address = new Uri(ConfigurationManager.AppSettings["service_address"]), Binding = "KAKA" }); client.SubscribeForEvent("PSC", new ReciverEndpointInfo { Address = new Uri(ConfigurationManager.AppSettings["service_address"]), Binding = "KAKA" }); factory.Close(); // Create a DiscoveryEndpoint that points to the DiscoveryProxy //Uri probeEndpointAddress = new Uri("net.tcp://localhost:8001/Probe"); //DiscoveryEndpoint discoveryEndpoint = new DiscoveryEndpoint(new NetTcpBinding(), new EndpointAddress(probeEndpointAddress)); //UdpDiscoveryEndpoint discoveryEndpoint = new UdpDiscoveryEndpoint(); // DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint); // Console.WriteLine("Finding IParallelPortService endpoints"); // Console.WriteLine(); try { // Find ICalculatorService endpoints //FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(IPortServerContract))); //Console.WriteLine("Found {0} IParallelPortService endpoint(s).", findResponse.Endpoints.Count); //Console.WriteLine(); // Check to see if endpoints were found, if so then invoke the service. } catch (TargetInvocationException) { Console.WriteLine("This client was unable to connect to and query the proxy. Ensure that the proxy is up and running."); } Console.WriteLine("Press <ENTER> to exit."); Console.ReadLine(); }
void HostReciverService() { try { reciver = new EventReciverService(); reciver.EventRecibed = OnRecive; host = new ServiceHost(reciver); host.Open(); } catch (Exception e) { MessageBox.Show("No se pudo hospedar el servicio para la recepcion de eventos.\nDetalle: " + e.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }