Esempio n. 1
0
        static void Main(string[] args)
        {
            //Client initalisieren
            Portal           system = new Portal(100);
            PortalCollection PC     = new PortalCollection();

            PC.RegisterPortal(system);

            system.IncomingPacket += OnSystemPacket;


            Thread.Sleep(1000);

            //while (online)
            //{
            int counter = 0;

            while (true)
            {
                while (Livinglist.Count < 500)
                {
                    lock (Livinglist_lock)
                    {
                        counter++;
                        Vaser.ConnectionSettings.VaserKerberosClient k = new Vaser.ConnectionSettings.VaserKerberosClient();
                        Link lnk1 = VaserClient.ConnectClient("localhost", 3100, PC, k);
                        lnk1.Disconnecting += OnDisconnectingLink;
                        lnk1.AttachedID     = (uint)counter;


                        if (lnk1 != null)
                        {
                            //Console.WriteLine("1: successfully established connection.");

                            Livinglist.Add(lnk1);
                        }
                    }
                    lock (Livinglist_lock)
                    {
                        counter++;
                        Vaser.ConnectionSettings.VaserKerberosClient k = new Vaser.ConnectionSettings.VaserKerberosClient();
                        Link lnk2 = VaserClient.ConnectClient("localhost", 3101, PC, k);
                        lnk2.Disconnecting += OnDisconnectingLink;
                        lnk2.AttachedID     = (uint)counter;

                        if (lnk2 != null)
                        {
                            //Console.WriteLine("2: successfully established connection.");

                            Livinglist.Add(lnk2);
                        }
                    }
                    Thread.Sleep(50);
                }
                Thread.Sleep(1000);
            }
            //Thread.Sleep(1);
            //Console.ReadKey();
            //}
        }
Esempio n. 2
0
        public static void ConnectionThread(object state)
        {
            OPTIONS.init();
            OPTIONS.Login.IncomingPacket += OnLoginPacket;
            OPTIONS.Chat.IncomingPacket  += OnChatPaket;

            try
            {
#if DEBUG
                OPTIONS.Connection = VaserClient.ConnectClient("localhost", 3100, OPTIONS.PColl);
                OPTIONS.Connection.Disconnecting += OnDisconnectingLink;
#else
                OPTIONS.Connection = VaserClient.ConnectClient(tb_ServerAddress.Text, 3100, OPTIONS.PColl);
                OPTIONS.Connection.Disconnecting += OnDisconnectingLink;
#endif
            }
            catch
            {
                Message msg = new Message();
                msg.command     = 2; //close
                msg.Messagedata = "Can't connect.";
                IncommingLogin.Enqueue(msg);

                ConnectingRunning = false;

                return;
            }

            SendL1.Username = Username;
            OPTIONS.Login.SendContainer(OPTIONS.Connection, SendL1, SEND_LOGIN.ContID, 0);

            ConnectingRunning = false;
        }
Esempio n. 3
0
 public void ConnectClient()
 {
     lnkC = VaserClient.ConnectClient("localhost", Port, PCollC);
     if (lnkC != null)
     {
         Console.WriteLine("1: successfully established connection.");
     }
 }
Esempio n. 4
0
        public void FailConnection()
        {
            Portal           system = new Portal(100);
            PortalCollection PColl  = new PortalCollection();

            PColl.RegisterPortal(system);
            Link lnkC = VaserClient.ConnectClient("localhost", 3110, PColl);
        }
Esempio n. 5
0
        static void Threads(object Context)
        {
            //Client initalisieren
            Portal           system = new Portal(100);
            PortalCollection PC     = new PortalCollection();

            PC.RegisterPortal(system);

            system.IncomingPacket += OnSystemPacket;


            Thread.Sleep(1000);

            //while (online)
            //{
            int counter = 0;

            lock (Livinglist_lock)
            {
                counter++;
                Vaser.ConnectionSettings.VaserKerberosClient k = new Vaser.ConnectionSettings.VaserKerberosClient();
                Link lnk1 = VaserClient.ConnectClient("wswinprev", 3500, PC, k);
                lnk1.Disconnecting += OnDisconnectingLink;
                lnk1.AttachedID     = (uint)counter;


                if (lnk1 != null)
                {
                    Console.WriteLine("1: successfully established connection.");

                    Livinglist.Add(lnk1);
                }
            }

            Thread.CurrentThread.Abort();
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        public static void start()
        {
            try
            {
                bool online = true;

                Thread.Sleep(1000);

                system = new Portal(100);
                PColl  = new PortalCollection();
                PColl.RegisterPortal(system);

                system.IncomingPacket += OnSystemPacket;

                while (online)
                {
                    while (Livinglist.Count < 10)
                    {
                        Link lnk1 = VaserClient.ConnectClient("localhost", 3100, PColl);
                        lnk1.Disconnecting += OnDisconnectingLink;
                        Link lnk2 = VaserClient.ConnectClient("localhost", 3101, PColl);
                        lnk2.Disconnecting += OnDisconnectingLink;

                        if (lnk1 != null)
                        {
                            //Console.WriteLine("1: successfully established connection.");
                            lock (Livinglist_lock)
                            {
                                Livinglist.Add(lnk1);
                            }
                        }
                        else
                        {
                            throw new Exception("Connerror!");
                        }
                        if (lnk2 != null)
                        {
                            //Console.WriteLine("2: successfully established connection.");
                            lock (Livinglist_lock)
                            {
                                Livinglist.Add(lnk2);
                            }
                        }
                        else
                        {
                            throw new Exception("Connerror!");
                        }
                    }

                    Thread.Sleep(1);
                    if (counter > 1000)
                    {
                        LongTimeTest.stop = true;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                lock (LongTimeTest.threadlock)
                {
                    LongTimeTest.error = true;
                    LongTimeTest.stop  = true;
                }
            }
        }
Esempio n. 8
0
        public static void Run()
        {
            bool online = true;

            //Client initalisieren
            Portal           system = new Portal(100);
            PortalCollection PC     = new PortalCollection();

            PC.RegisterPortal(system);
            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!
            // ###########################################################


            /*//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");
            }

            while (online)
            {
                Thread.Sleep(100);

                //entfernen
                if (lnk1.IsConnected == false)
                {
                    online = false;
                }
            }
            //Client1.CloseClient();
            lnk1.Dispose();

            Console.WriteLine("Test ended... press any key...");
            Console.ReadKey();
        }