public MainWindow() { InitializeComponent(); var channel = XDChannelFactory.GetLocalChannel(Settings.Default.ChannelName_Status, Settings.Default.TransportMode); broadcast = channel.CreateBroadcast(); listener = channel.CreateListener(listener_MessageReceived); }
public void Start() { Console.WriteLine(string.Format("Register Channel '{0}'", Settings.Default.ChannelName_Commands)); var channel = XDChannelFactory.GetLocalChannel(Settings.Default.ChannelName_Commands, Settings.Default.TransportMode); broadcast = channel.CreateBroadcast(); listener = channel.CreateListener(MessageReceived); broadcast.SendToChannel(Settings.Default.ChannelName_Status, "Process started!"); }
public static void StartPrcMessaging() { if (_broadcast != null) { return; } _broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.WindowsMessaging, false); _listener = XDListener.CreateListener(XDTransportMode.WindowsMessaging); _listener.MessageReceived += Listener_MessageReceived; _listener.RegisterChannel(channel); }
public CommManager() { this.otherInstances = new List <LogViewerInstance>(); this.listener = XDListener.CreateListener(XDTransportMode.WindowsMessaging); this.broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.WindowsMessaging, false); this.listener.RegisterChannel(myID.ToString()); //Channel only for me this.listener.RegisterChannel(ChannelBroadcast); //Channel for everyone listener.MessageReceived += new XDListener.XDMessageHandler(listener_MessageReceived); this.MainWindowHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; }
/// <summary> /// Default constructor. /// </summary> public TestService() { InitializeComponent(); this.ServiceName = "Test Service"; //only the following mode is supported in windows services broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.IOStream); listener = XDListener.CreateListener(XDTransportMode.IOStream); listener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived); listener.RegisterChannel("Status"); listener.RegisterChannel("Channel1"); listener.RegisterChannel("Channel2"); }
public static bool EndProfiling(string dataProvider) { // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = null; IDataProvider provider = esProviderFactory.Factory.GetDataProvider(dataProvider, "DataProvider"); if (provider != null) { provider.TraceHandler -= profileListener.MyTraceEventHandler; } return true; }
public void TestMethod1() { string channelName = "testChannel"; IXDChannel channel = XDChannelFactory.GetLocalChannel(channelName, XDTransportMode.IOStream); IXDBroadcast broadcast = channel.CreateBroadcast(); IXDListener listener = channel.CreateListener(MessageReceived); broadcast.SendToChannel(channelName, "test"); while (waitForMessage) { Thread.Sleep(200); } Assert.IsFalse(waitForMessage); }
public static bool EndProfiling(string dataProvider) { // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = null; IDataProvider provider = tgProviderFactory.Factory.GetDataProvider(dataProvider, "DataProvider"); if (provider != null) { provider.TraceHandler -= profileListener.MyTraceEventHandler; } return(true); }
/// <summary> /// Default constructor. /// </summary> /// <param name="nativeBroadcast"></param> /// <param name="propagateListener"></param> internal NetworkRelayListener(IXDBroadcast nativeBroadcast, IXDListener propagateListener) { if (nativeBroadcast == null) { throw new ArgumentNullException("nativeBroadcast"); } if (propagateListener == null) { throw new ArgumentNullException("propagateListener"); } this.nativeBroadcast = nativeBroadcast; this.propagateListener = propagateListener; // listen on the network channel for this mode this.propagateListener.RegisterChannel(NetworkRelayBroadcast.GetPropagateNetworkMailSlotName(nativeBroadcast)); this.propagateListener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived); }
/// <summary> /// Default constructor. /// </summary> /// <param name="nativeBroadcast"></param> /// <param name="propagateListener"></param> internal NetworkRelayListener(IXDBroadcast nativeBroadcast, IXDListener propagateListener) { if (nativeBroadcast == null) { throw new ArgumentNullException("nativeBroadcast"); } if (propagateListener == null) { throw new ArgumentNullException("propagateListener"); } this.nativeBroadcast = nativeBroadcast; this.propagateListener = propagateListener; // listen on the network channel for this mode this.propagateListener.RegisterChannel(NetworkRelayBroadcast.GetPropagateNetworkMailSlotName(nativeBroadcast)); this.propagateListener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived); }
public static bool BeginProfiling(string dataProvider, string channel) { IDataProvider provider = esProviderFactory.Factory.GetDataProvider(dataProvider, "DataProvider"); if (provider != null) { if (!provider.IsTracing) { // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.IOStream); provider.TraceChannel = channel; provider.TraceHandler += profileListener.MyTraceEventHandler; } } return true; }
/// <summary> /// Initialize the broadcast and listener mode. /// </summary> /// <param name="mode">The new mode.</param> private void InitializeMode(XDTransportMode mode) { if (listener != null) { // ensure we dispose any previous listeners, dispose should aways be // called on IDisposable objects when we are done with it to avoid leaks listener.Dispose(); } // creates an instance of the IXDListener object using the given implementation listener = XDListener.CreateListener(mode); // attach the message handler listener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived); // register the channels we want to listen on if (statusCheckBox.Checked) { listener.RegisterChannel("Status"); } // register if checkbox is checked if (channel1Check.Checked) { listener.RegisterChannel("Channel1"); } // register if checkbox is checked if (channel2Check.Checked) { listener.RegisterChannel("Channel2"); } // if we already have a broadcast instance if (broadcast != null) { broadcast.SendToChannel("Status", string.Format("{0} is changing mode to {1}", this.Handle, mode)); } // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(mode, propagateCheck.Checked); }
/// <summary> /// Initialize the broadcast and listener mode. /// </summary> /// <param name="mode">The new mode.</param> public static void InitializeMode(XDTransportMode mode) { if (listener != null) { // ensure we dispose any previous listeners, dispose should aways be // called on IDisposable objects when we are done with it to avoid leaks listener.Dispose(); } listener = XDListener.CreateListener(mode); // attach the message handler listener.MessageReceived += OnMessageReceived; listener.RegisterChannel(CHANNEL_NAME); // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(mode, false); }
public static bool BeginProfiling(string dataProvider, string channel) { IDataProvider provider = tgProviderFactory.Factory.GetDataProvider(dataProvider, "DataProvider"); if (provider != null) { if (!provider.IsTracing) { // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.IOStream); provider.TraceChannel = channel; provider.TraceHandler += profileListener.MyTraceEventHandler; } } return(true); }
/// <summary> /// The default constructor used to wrap a native broadcast implementation. /// </summary> /// <param name="nativeBroadcast"></param> /// <param name="networkBroadcast"></param> internal NetworkRelayBroadcast(IXDBroadcast nativeBroadcast, IXDBroadcast networkBroadcast) { if (nativeBroadcast == null) { throw new ArgumentNullException("nativeBroadcast"); } if (networkBroadcast == null) { throw new ArgumentNullException("networkBroadcast"); } if (nativeBroadcast.GetType() == typeof(XDMailSlotBroadcast)) { throw new ArgumentException("Cannot be of type XDMailSlotBroadcast.", "nativeBroadcast"); } this.mailSlotName = GetPropagateNetworkMailSlotName(nativeBroadcast); // the native broadcast that this implementation wrappers this.nativeBroadcast = nativeBroadcast; // the MailSlot broadcast implementation is used to send over the network this.networkBroadcast = networkBroadcast; }
/// <summary> /// The default constructor used to wrap a native broadcast implementation. /// </summary> /// <param name="nativeBroadcast"></param> /// <param name="networkBroadcast"></param> internal NetworkRelayBroadcast(IXDBroadcast nativeBroadcast, IXDBroadcast networkBroadcast) { if (nativeBroadcast == null) { throw new ArgumentNullException("nativeBroadcast"); } if (networkBroadcast == null) { throw new ArgumentNullException("networkBroadcast"); } if (nativeBroadcast.GetType() == typeof(XDMailSlotBroadcast)) { throw new ArgumentException("Cannot be of type XDMailSlotBroadcast.", "nativeBroadcast"); } this.mailSlotName = GetPropagateNetworkMailSlotName(nativeBroadcast); // the native broadcast that this implementation wrappers this.nativeBroadcast = nativeBroadcast; // the MailSlot broadcast implementation is used to send over the network this.networkBroadcast = networkBroadcast; }
/// <summary> /// Creates an instance of IXDBroadcast with the otption to propagate over the local network. /// </summary> /// <param name="mode">The broadcast mode.</param> /// <param name="propagateNetwork">true to propagate messages over the local network.</param> /// <returns></returns> public static IXDBroadcast CreateBroadcast(XDTransportMode mode, bool propagateNetwork) { // MailSlots can communicate over a network by default, so // no need to use the NetworkRelayBroadcast instance for this type. if (mode == XDTransportMode.MailSlot) { return(new XDMailSlotBroadcast(propagateNetwork)); } IXDBroadcast broadcast = CreateBroadcast(mode); if (propagateNetwork) { // create a wrapper to broadcast that will also send messages over network return(new NetworkRelayBroadcast(broadcast, XDBroadcast.CreateBroadcast(XDTransportMode.MailSlot, true))); } else { return(broadcast); } }
/// <summary> /// Gets the unique network propagation MailSlot name. /// </summary> /// <param name="nativeBroadcast"></param> /// <returns></returns> internal static string GetPropagateNetworkMailSlotName(IXDBroadcast nativeBroadcast) { // each mode has a unique MailSlot ident for monitoring network traffic return string.Concat(NetworkPropagateChannel, ".", nativeBroadcast.GetType().Name); }
/// <summary> /// Gets the unique network propagation MailSlot name. /// </summary> /// <param name="nativeBroadcast"></param> /// <returns></returns> internal static string GetPropagateNetworkMailSlotName(IXDBroadcast nativeBroadcast) { // each mode has a unique MailSlot ident for monitoring network traffic return(string.Concat(NetworkPropagateChannel, ".", nativeBroadcast.GetType().Name)); }