public void Execute() { logger.Info("Executing UdpTestClient"); //create utility bus Niawa.Utilities.UtilsServiceBus utilsBus = new Niawa.Utilities.UtilsServiceBus(); //set up ipc logging Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter evtWriter = new Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter(utilsBus); evtWriter.Start(); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "UdpReceiver", utilsBus), "UdpReceiver"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "UdpReceiverMsg", utilsBus), "UdpReceiverMsg"); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "UdpTransmitter", utilsBus), "UdpTransmitter"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "UdpTransmitterMsg", utilsBus), "UdpTransmitterMsg"); transmitter = new Niawa.NetController.UdpTransmitter(_port, evtWriter.EvtConsumer, utilsBus, "TestApp.UdpTestClient", null); receiver = new Niawa.NetController.UdpReceiver(_port, evtWriter.EvtConsumer, utilsBus, "TestApp.UdpTestClient", null, true, transmitter); receiver.StartListening("UdpTestClient"); transmitter.StartTransmitting("UdpTestClient"); System.Threading.Thread t1 = new System.Threading.Thread(StateChangeThreadImpl); System.Threading.Thread t2 = new System.Threading.Thread(SendMessageThreadImpl); t1.Start(); t2.Start(); }
/// <summary> /// Instantiates a new IpcEventTreeModelAdapter. /// </summary> /// <param name="formWindow"></param> /// <param name="formTreeView"></param> public IpcEventTreeModelAdapter(Forms.IpcTreeWebWindow formWindow, Forms.IpcEventMonitorMdiWindow mdiWindow, System.Windows.Forms.TreeView formTreeView) { _webURL = "file:///{0}/Html/IpcEventMonitorPane.html"; _formWindow = formWindow; _mdiWindow = mdiWindow; _formTreeView = formTreeView; _webBrowser = _formWindow.WebBrowser1; //create utility bus _utilsBus = new Niawa.Utilities.UtilsServiceBus(); //set up ipc logging for this class (to log events that occur in the tree model) _evtWriter = new Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter(_utilsBus); _evtWriter.Start(); _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("IpcEventMonitor", true, "TreeModel", _utilsBus), "TreeModel"); //instantiate view _view = new TreeModel.TreeModelViewImpl(_formWindow, _formTreeView); //instantiate node view factory _nodeViewFactory = new TreeModel.TreeModelNodeViewFactoryImpl(_webBrowser, _webURL); //instantiate tree model controller _treeModelController = new TreeModelNodeControls.TreeModelController(_view, _nodeViewFactory, _evtWriter.EvtConsumer, "IpcEventMonitor", string.Empty); }
/// <summary> /// Creates a NiawaAdHocNetworkAdapter /// </summary> /// <param name="udpPort"></param> /// <param name="ipAddress"></param> /// <param name="tcpPortRangeMin"></param> /// <param name="tcpPortRangeMax"></param> /// <param name="hostname"></param> /// <param name="applicationName"></param> public NiawaAdHocNetworkAdapter(int udpPort, string ipAddress, int tcpPortRangeMin, int tcpPortRangeMax, string hostname, string applicationName) { try { _description = "NiawaAdHocNetworkAdapter"; _udpPort = udpPort; _ipAddress = ipAddress; _tcpPortRangeMin = tcpPortRangeMin; _tcpPortRangeMax = tcpPortRangeMax; _hostname = hostname; _applicationName = applicationName; //create utility bus _utilsBus = new Niawa.Utilities.UtilsServiceBus(); //set up ipc logging _evtWriter = new Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter(_utilsBus); _evtWriter.Start(); //initialize event logging for this object _evtRaiser = new MsEventController.EventRaiser("NiawaAdHocNetworkAdapter", _applicationName, _description, _utilsBus); if (_evtWriter.EvtConsumer != null) _evtRaiser.AddEventConsumer(_evtWriter.EvtConsumer); //add ipc logging for this object _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "NiawaAdHocNetworkAdapter", _utilsBus), "NiawaAdHocNetworkAdapter"); //add ipc logging for UDP _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "UdpReceiver", _utilsBus), "UdpReceiver"); //_evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "UdpReceiverMsg", _utilsBus), "UdpReceiverMsg"); _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "UdpTransmitter", _utilsBus), "UdpTransmitter"); //_evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "UdpTransmitterMsg", _utilsBus), "UdpTransmitterMsg"); //add ipc logging for TCP _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpReceiver", _utilsBus), "TcpReceiver"); //_evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpReceiverMsg", _utilsBus), "TcpReceiverMsg"); _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpTransmitter", _utilsBus), "TcpTransmitter"); //_evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpTransmitterMsg", _utilsBus), "TcpTransmitterMsg"); //add ipc logging for TcpSession _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpSession", _utilsBus), "TcpSession"); //add ipc logging for TcpSessionManager _evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpSessionManager", _utilsBus), "TcpSessionManager"); //_evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter(_applicationName, true, "TcpSessionManagerMsg", _utilsBus), "TcpSessionManagerMsg"); //ipc command reader _cmdReader = new IpcController.IpcCommandReader("NiawaAdHocNetworkAdapterCmd", CmdReaderImpl, _utilsBus, true); //thread health and status _threadStatus = new Niawa.Threading.ThreadStatus(_description, 60, _utilsBus.InitializeSerialId(Niawa.Utilities.IdGeneratorUtils.ID_ROOT_NIAWA_THREAD_ID).ToString(), string.Empty, _evtRaiser); _healthMonitor = new ThreadHealthMonitor(this); //thread status _threadStatus.Status = Niawa.Threading.ThreadStatus.STATUS_INITIALIZED; //add thread elective properties. _threadStatus.AddElectiveProperty("IpAddress", _ipAddress); _threadStatus.AddElectiveProperty("TcpPortRangeMin", _tcpPortRangeMin.ToString()); _threadStatus.AddElectiveProperty("TcpPortRangeMax", _tcpPortRangeMax.ToString()); _threadStatus.AddElectiveProperty("UdpPort", _udpPort.ToString()); _threadStatus.AddElectiveProperty("Hostname", _hostname); } catch (Exception ex) { logger.Error("[NiawaAdHocNetworkAdapter-M] Error while instantiating: " + ex.Message, ex); throw ex; } }
public void ExecuteTcpUnitTest0() { logger.Info(">>"); logger.Info("Program started"); //my IP address System.Net.IPAddress myAddress = Niawa.Utilities.NetUtils.FindLanAddress(); int myPort = 2150; //remote client IP address System.Net.IPAddress remoteAddress = System.Net.IPAddress.Parse("192.168.2.6"); int remotePort = 2150; //create utility bus Niawa.Utilities.UtilsServiceBus utilsBus = new Niawa.Utilities.UtilsServiceBus(); //set up ipc logging Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter evtWriter = new Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter(utilsBus); evtWriter.Start(); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpReceiver", utilsBus), "TcpReceiver"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpReceiverMsg", utilsBus), "TcpReceiverMsg"); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpTransmitter", utilsBus), "TcpTransmitter"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpTransmitterMsg", utilsBus), "TcpTransmitterMsg"); //receiver logger.Info("Test receiver"); Niawa.NetController.TcpReceiver receiver = new Niawa.NetController.TcpReceiver(myAddress.ToString(), myPort, "(local)", evtWriter.EvtConsumer, utilsBus, "TestApp.TestClient", null); receiver.StartListening("TestClient"); System.Threading.Thread.Sleep(1500); //transmitter logger.Info("Test transmitter"); Niawa.NetController.TcpTransmitter transmitter = new Niawa.NetController.TcpTransmitter(remoteAddress.ToString(), remotePort, evtWriter.EvtConsumer, utilsBus, "TestApp.TestClient", null); transmitter.StartTransmitting("TestClient"); System.Threading.Thread.Sleep(1500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType1", "testMsg contents 1")); System.Threading.Thread.Sleep(500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType2", "testMsg contents 2")); System.Threading.Thread.Sleep(1500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType3", "testMsg contents 3")); System.Threading.Thread.Sleep(500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType4", "testMsg contents 4")); System.Threading.Thread.Sleep(500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType5", "testMsg contents 5")); System.Threading.Thread.Sleep(1500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType6", "testMsg contents 6")); System.Threading.Thread.Sleep(1500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType7", "testMsg contents 7")); System.Threading.Thread.Sleep(1500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType8", "testMsg contents 8")); System.Threading.Thread.Sleep(500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType9", "testMsg contents 9")); System.Threading.Thread.Sleep(1500); //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType10", "testMsg contents 10")); System.Threading.Thread.Sleep(500); System.Threading.Thread.Sleep(3000); transmitter.StopTransmitting("TestClient", false); System.Threading.Thread.Sleep(1000); receiver.StopListening("TestClient", false); System.Threading.Thread.Sleep(1000); transmitter = null; receiver = null; logger.Info("Program stopped <<"); }
public void ExecuteUdpUnitTest1() { logger.Info(">>"); logger.Info("Program started"); //create utility bus Niawa.Utilities.UtilsServiceBus utilsBus = new Niawa.Utilities.UtilsServiceBus(); //set up ipc logging Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter evtWriter = new Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter(utilsBus); evtWriter.Start(); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "UdpReceiver", utilsBus), "UdpReceiver"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpReceiverMsg", utilsBus), "TcpReceiverMsg"); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "UdpTransmitter", utilsBus), "UdpTransmitter"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpTransmitterMsg", utilsBus), "TcpTransmitterMsg"); Niawa.NetController.UdpTransmitter transmitter = new Niawa.NetController.UdpTransmitter(5001, evtWriter.EvtConsumer, utilsBus, "TestApp.TestClient", null); transmitter.StartTransmitting("TestClient"); Niawa.NetController.UdpReceiver receiver = new Niawa.NetController.UdpReceiver(5001, evtWriter.EvtConsumer, utilsBus, "TestApp.TestClient", null, true, transmitter); receiver.StartListening("TestClient"); bool active = true; int ix = 0; while (active) { string lanAddress = Niawa.Utilities.NetUtils.FindLanAddress().ToString(); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg " + lanAddress + " contents " + ix)); System.Threading.Thread.Sleep(1500); ix++; } /* receiver.SuspendListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); transmitter.SendMessage(new NetController.NiawaNetDatagram(Niawa.Utilities.NetUtils.FindLanAddress().ToString(), 5001, Guid.NewGuid(), "testHost", "testApp", "testMsgType", "testMsg contents 1")); receiver.ResumeListening("TestClient"); */ System.Threading.Thread.Sleep(1500); logger.Info("Program stopped <<"); }
public void ExecuteTcpUnitTest1() { logger.Info(">>"); logger.Info("Program started"); //my IP address System.Net.IPAddress myAddress = Niawa.Utilities.NetUtils.FindLanAddress(); int myPort = 2150; //remote client IP address System.Net.IPAddress remoteAddress = null; if (myAddress.ToString() == "192.168.2.14") remoteAddress = System.Net.IPAddress.Parse("192.168.2.6"); else if (myAddress.ToString() == "192.168.2.6") remoteAddress = System.Net.IPAddress.Parse("192.168.2.14"); else throw new Exception("The current IP address [" + myAddress.ToString() + "] doesn't have a configured test remote value"); int remotePort = 2150; //create utility bus Niawa.Utilities.UtilsServiceBus utilsBus = new Niawa.Utilities.UtilsServiceBus(); //set up ipc logging Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter evtWriter = new Niawa.MsEventIpcEventAdapter.MsEventIpcEventWriter(utilsBus); evtWriter.Start(); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpReceiver", utilsBus), "TcpReceiver"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpReceiverMsg", utilsBus), "TcpReceiverMsg"); evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpTransmitter", utilsBus), "TcpTransmitter"); //evtWriter.AddIpcEventWriter(Niawa.IpcController.IpcFactory.CreateIpcEventWriter("Niawa.NetControllerTestClient", true, "TcpTransmitterMsg", utilsBus), "TcpTransmitterMsg"); //receiver logger.Info("Test receiver"); Niawa.NetController.TcpReceiver receiver = new Niawa.NetController.TcpReceiver(myAddress.ToString(), myPort, "(local)", evtWriter.EvtConsumer, utilsBus, "TestApp.TestClient", null); receiver.StartListening("TestClient"); //System.Threading.Thread.Sleep(1500); //transmitter logger.Info("Test transmitter"); Niawa.NetController.TcpTransmitter transmitter = new Niawa.NetController.TcpTransmitter(remoteAddress.ToString(), remotePort, evtWriter.EvtConsumer, utilsBus, "TestApp.TestClient", null); transmitter.StartTransmitting("TestClient"); System.Threading.Thread.Sleep(1500); bool doneTesting = false; int ix = 0; while (!doneTesting) { ix++; //send test message transmitter.SendMessage(new NetController.NiawaNetMessage(myAddress.ToString(), myPort, "TestHost", remoteAddress.ToString(), remotePort, "TestHost", Guid.NewGuid(), "testApp", "testMsgType" + ix, "testMsg contents " + ix)); System.Threading.Thread.Sleep(2500); } transmitter.StopTransmitting("TestClient", false); System.Threading.Thread.Sleep(1000); receiver.StopListening("TestClient", false); System.Threading.Thread.Sleep(1000); transmitter = null; receiver = null; logger.Info("Program stopped <<"); }