Esempio n. 1
0
        static void Main(string[] args)
        {
            int v = 3;

            if (v == 1)
            {
                Scheme2 s = new Scheme2();
                s.Start();
            }
            if (v == 2)
            {
                Scheme1 s = new Scheme1();
                Thread t = s.Start();
                t.Join();
            }
            if (v == 3)
            {
                Scheme3 s = new Scheme3();
                while (true)
                {
                    s.Start();
                }
            }
        }
Esempio n. 2
0
        public void Start()
        {
            int stepCtr1 = 0;
            int stepCtr2 = 0;
            string nm = Datagen.GetFirstName();
            string msg = "";
            client = new Scheme3();
            //client.HostName = "74.208.133.86";
            client.HostName = "127.0.0.1";
            client.EnableDataGenerator = false;
            client.TimerInterval = 200;
            Thread t = new Thread(new ThreadStart(client.StartClient));
            t.Start();
            msg = nm;
            Thread.Sleep(1000);
            string sendmsg = string.Format("LOGIN /lobby CHAT/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length, msg);
            client.Send(sendmsg);
            string sendstockmsg = string.Format("SUBSCRIBE INTC STOCK/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length, msg);
            client.Send(sendstockmsg);

            while (inLoop)
            {
                Thread.Sleep(5000);
                msg = Datagen.GetComment();
                client.Send(string.Format("SAY /lobby CHAT/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length ,msg));
                Thread.Sleep(1000);
                string msg2 = GameStep(stepCtr1, nm);
                //Console.WriteLine(string.Format("=========================\nSending===>{0}\n\n", msg2));
                client.Send(msg2);

                if (stepCtr2 < 3)
                {
                    string sendstockmsg3 = string.Format("SUBSCRIBE INTC STOCK/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length, msg);
                    client.Send(sendstockmsg3);
                    Thread.Sleep(1000);
                    sendstockmsg3 = string.Format("SUBSCRIBE TSLA STOCK/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length, msg);
                    client.Send(sendstockmsg3);
                    Thread.Sleep(1000);
                    sendstockmsg3 = string.Format("SUBSCRIBE MSFT STOCK/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length, msg);
                    client.Send(sendstockmsg3);
                    Thread.Sleep(1000);
                    sendstockmsg3 = string.Format("SUBSCRIBE NKE STOCK/1.0\nname={0}\ncontent-length:{1}\n\n{2}\n\n", nm, msg.Length, msg);
                    client.Send(sendstockmsg3);
                }

                stepCtr1++;
                stepCtr2++;
            }
            //t.Join();
        }