public void HandleIncomingPacket_XMLFetch(PacketHeader header, Connection connection, string incomingString) { //NetManager propTest = new NetManager(); MessagesClass propTest = new MessagesClass(); //WinViewer.WinViewer winViewer = new WinViewer.WinViewer(); Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); string passMessage = File.ReadLines("inv.xml").First(); propTest.sendMessages(passMessage, "XMLInfo"); }
//public NetManager(string passMessage, string passAddress, bool peerSend, int peerExitCode) //{ // peerMessage = passMessage; // peerAddress = passAddress; // sendMessage = peerSend; // exitCode = peerExitCode; //} public void netShutdown() { MessagesClass netClose = new MessagesClass(); netClose.netShutdown1(); NetworkComms.RemoveGlobalIncomingPacketHandler(); //exitCode = 1; NetworkComms.Shutdown(); }
public void HandleIncomingPacket_DecAddFin(PacketHeader header, Connection connection, string incomingString) { //NetManager propTest = new NetManager(); MessagesClass propTest = new MessagesClass(); //WinViewer.WinViewer winViewer = new WinViewer.WinViewer(); Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); TextWriter twMonPos = File.CreateText("monPosition.xml"); twMonPos.Close(); propTest.sendMessages("", "XMLFetch"); }
//public NetManager(string passMessage, string passAddress, bool peerSend, int peerExitCode) //{ // peerMessage = passMessage; // peerAddress = passAddress; // sendMessage = peerSend; // exitCode = peerExitCode; //} public void RunExample() { //NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", HandleIncomingMessagePacket); //NetworkComms.AppendGlobalIncomingPacketHandler<string>(""); //MessagesClass propTest1 = new MessagesClass("defaultMessage", null, false, 0); MessagesClass propTest = new MessagesClass(); //propTest1 = null; Thread messagesClass = new Thread(new ThreadStart(propTest.RunExample1)); //messagesClass.Start(); //TextWriter tw = File.CreateText("test.txt"); //tw.WriteLine(propTest1); //tw.WriteLine(messagesClass); //tw.Close(); //NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions<ProtobufSerializer, LZMACompressor>(); //Ensure the packet construction time is included in all sent packets //NetworkComms.DefaultSendReceiveOptions.IncludePacketConstructionTime = true; //Ensure all incoming packets are handled with the priority AboveNormal //NetworkComms.DefaultSendReceiveOptions.ReceiveHandlePriority = QueueItemPriority.AboveNormal; NetworkComms.AppendGlobalIncomingPacketHandler <string>("DecAddFin", HandleIncomingPacket_DecAddFin); NetworkComms.AppendGlobalIncomingPacketHandler <string>("XMLInfo", HandleIncomingPacket_XMLInfo); NetworkComms.AppendGlobalIncomingPacketHandler <string>("MONPos", HandleIncomingPacket_MONPos); //NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", HandleIncomingMessagePacket); //NetworkComms.RemoveGlobalIncomingPacketHandler<string>("Message", HandleIncomingMessagePacket); messagesClass.Start(); //MessagesClass messagesClass = new MessagesClass(); //messagesClass.RunExample1(); //propTest1 = null; }
public void HandleIncomingPacket_XMLInfo(PacketHeader header, Connection connection, string incomingString) { //NetManager propTest = new NetManager(); MessagesClass propTest = new MessagesClass(); //WinViewer.WinViewer winViewer = new WinViewer.WinViewer(); Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); /*TextWriter tw = File.CreateText("inv.xml"); * tw.WriteLine(incomingString); * tw.Close();*/ using (StreamWriter swXMLInfo = new StreamWriter("inv.xml", true)) { swXMLInfo.WriteLine(incomingString); } propTest.sendMessages("", "MONFetch"); }
public void RunExample() { //NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", HandleIncomingMessagePacket); //NetworkComms.AppendGlobalIncomingPacketHandler<string>(""); //MessagesClass propTest1 = new MessagesClass("defaultMessage", null, false, 0); MessagesClass propTest1 = new MessagesClass(); Thread messagesClass = new Thread(new ThreadStart(propTest1.RunExample1)); //messagesClass.Start(); //NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions<ProtobufSerializer, LZMACompressor>(); //Ensure the packet construction time is included in all sent packets //NetworkComms.DefaultSendReceiveOptions.IncludePacketConstructionTime = true; //Ensure all incoming packets are handled with the priority AboveNormal //NetworkComms.DefaultSendReceiveOptions.ReceiveHandlePriority = QueueItemPriority.AboveNormal; NetworkComms.AppendGlobalIncomingPacketHandler <string>("DecAdd", HandleIncomingPacket_DecAdd); NetworkComms.AppendGlobalIncomingPacketHandler <string>("XMLFetch", HandleIncomingPacket_XMLFetch); NetworkComms.AppendGlobalIncomingPacketHandler <string>("MONFetch", HandleIncomingPacket_MONFetch); //NetworkComms.AppendGlobalIncomingPacketHandler<string>("ScrnDims", HandleIncomingPacket_ScrnDims); //NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", HandleIncomingMessagePacket); messagesClass.Start(); //MessagesClass messagesClass = new MessagesClass(); //messagesClass.RunExample1(); }
public void HandleIncomingPacket_MONFetch(PacketHeader header, Connection connection, string incomingString) { //NetManager propTest = new NetManager(); MessagesClass propTest = new MessagesClass(); //WinViewer.WinViewer winViewer = new WinViewer.WinViewer(); Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); string monPos = System.Windows.Forms.Screen.AllScreens.ToString(); //TextWriter tw = File.CreateText("monPos.txt"); //tw.WriteLine(monPos); foreach (var screen in System.Windows.Forms.Screen.AllScreens) { //tw2.WriteLine(screen.Bounds.ToString()); monPos = screen.Bounds.ToString(); propTest.sendMessages(monPos, "MONPos"); } //tw.Close(); }
public void HandleIncomingPacket_DecAdd(PacketHeader header, Connection connection, string incomingString) { //NetManager propTest = new NetManager(); MessagesClass propTest = new MessagesClass(); //WinViewer.WinViewer winViewer = new WinViewer.WinViewer(); Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); string[] splitAddress = connection.ToString().Split('>'); string halfDecodedAddress = splitAddress[1]; string[] splitAddress1 = halfDecodedAddress.ToString().Split('('); string decodedAddress = splitAddress1[0]; string peerAddress = decodedAddress.Replace(" ", ""); TextWriter tw = File.CreateText("peerAddress.txt"); tw.WriteLine(peerAddress); tw.Close(); Console.WriteLine("decodeAddress"); propTest.sendMessages("", "DecAddFin"); }
//TextWriter twMonPos = File.CreateText("monPosition.xml"); public void HandleIncomingPacket_MONPos(PacketHeader header, Connection connection, string incomingString) { //NetManager propTest = new NetManager(); MessagesClass propTest = new MessagesClass(); //WinViewer.WinViewer winViewer = new WinViewer.WinViewer(); Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); using (StreamWriter swMonPos = new StreamWriter("monPosition.xml", true)) { swMonPos.WriteLine(incomingString); } //TextWriter twMonPos = File.CreateText("monPosition.xml"); //twMonPos.WriteLine(incomingString); //propTest.sendMessages("", "ScrnDims"); //tw.WriteLine(incomingString); //tw.Close(); }