static void Main(string[] args) { bool online = true; //Client initalisieren Portal system = new Portal(100); PortalCollection PC = new PortalCollection(); PC.RegisterPortal(system); system.IncomingPacket += OnSystemPacket; TestRequest myRequest = new TestRequest(); PC.RegisterRequest(myRequest, system, 501); TestChannel myChannel = new TestChannel(); PC.RegisterChannel(myChannel, system, 502); // ########################################################### // Create a TestCert in CMD: makecert -sr LocalMachine -ss root -r -n "CN=localhost" -sky exchange -sk 123456 // Do not use in Production | do not use localhost -> use your machinename! // ########################################################### /*//Import Test Cert from local store * X509Certificate2Collection cCollection = new X509Certificate2Collection(); * * X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine); * store.Open(OpenFlags.ReadOnly); * var certificates = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, "CN=localhost", false); * store.Close(); * * if (certificates.Count == 0) * { * Console.WriteLine("Server certificate not found..."); * Console.ReadKey(); * return; * } * else * { * cCollection.Add(certificates[0]); * } * // Get the value. * string resultsTrue = cCollection[0].ToString(true); * // Display the value to the console. * Console.WriteLine(resultsTrue); * // Get the value. * string resultsFalse = cCollection[0].ToString(false); * // Display the value to the console. * Console.WriteLine(resultsFalse);*/ /*System.Timers.Timer _aTimer = new System.Timers.Timer(1); * _aTimer.Elapsed += DoPackets; * _aTimer.AutoReset = true; * _aTimer.Enabled = true;*/ Thread.Sleep(100); VaserSSLClient ssl = new VaserSSLClient("localhost"); VaserKerberosClient kerberos = new VaserKerberosClient(); Link lnk1 = VaserClient.ConnectClient("localhost", 3100, PC); lnk1.EmptyBuffer += OnEmptyBuffer; if (lnk1 != null) { Console.WriteLine("1: successfully established connection."); } //working if (lnk1.IsConnected) { Console.WriteLine("Test. Con OK"); } cStatus sts = myRequest.myRequestStarter("HELLO WORLD!", lnk1); myChannel.mySendStarter("This is my channel tester", lnk1); while (online) { if (sts != null) { if (sts.Done && !sts.Error) { Console.WriteLine("Request Done Result: " + (string)sts.ResultObject); sts = null; online = false; } if (sts != null && sts.Error) { Console.WriteLine("Error: " + sts.Message); sts = null; online = false; } } Thread.Sleep(1000); //entfernen //if (lnk1.IsConnected == false) online = false; } //Client1.CloseClient(); lnk1.Dispose(); Console.WriteLine("Test ended... press any key..."); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Welcome to the Vaser testengine"); Console.WriteLine("Prepareing server"); Console.WriteLine(""); Console.WriteLine("Creating container: TestContainer"); //create connection managing lists //initialize the server Console.WriteLine("Creating portal: system"); system = new Portal(100); PortalCollection PC = new PortalCollection(); PC.RegisterPortal(system); TestRequest myRequest = new TestRequest(); PC.RegisterRequest(myRequest, system, 501); TestChannel myChannel = new TestChannel(); PC.RegisterChannel(myChannel, system, 502); system.IncomingPacket += OnSystemPacket; // ########################################################### // Create a TestCert in CMD: makecert -sr LocalMachine -ss root -r -n "CN=localhost" -sky exchange -sk 123456 // Do not use in Production | do not use localhost -> use your machinename! // ########################################################### /*Console.WriteLine("Import Test Cert"); * //Import Test Cert * X509Certificate2 cert = new X509Certificate2(); * * X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine); * store.Open(OpenFlags.ReadOnly); * var certificates = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, "CN=localhost", false); * store.Close(); * * if (certificates.Count == 0) * { * Console.WriteLine("Server certificate not found"); * Console.ReadKey(); * return; * } * else * { * Console.WriteLine("Test Cert was found"); * } * * // Get the value. * string resultsTrue = cert.ToString(true); * // Display the value to the console. * Console.WriteLine(resultsTrue); * // Get the value. * string resultsFalse = cert.ToString(false); * // Display the value to the console. * Console.WriteLine(resultsFalse); */ //start the server Console.WriteLine("Creating server: IPAddress any, Port 3100, VaserMode ModeSSL"); //VaserSSLServer ssl = new VaserSSLServer(certificates[0]); VaserKerberosServer kerberos = new VaserKerberosServer(); VaserServer Server1 = new VaserServer(System.Net.IPAddress.Any, 3100, PC); Server1.NewLink += OnNewLink; Server1.DisconnectingLink += OnDisconnectingLink; Server1.Start(); Console.WriteLine(""); bool online = true; //working while (online) { switch (testmode) { case 0: Console.WriteLine("Test 1: Connection and Transfer statistics:"); Console.WriteLine("Waiting for Connection..."); testmode = 1; break; case 4: //test1.Dispose(); Console.WriteLine("Closed"); Thread.Sleep(500); testmode = -1; break; } if (testmode == -1) { break; } //Time tick Thread.Sleep(1); } Thread.Sleep(5000); //close Server Console.WriteLine("Close Server"); Server1.Stop(); Console.WriteLine("Test ended. Press any key..."); Console.ReadKey(); }