Exemplo n.º 1
0
        public bool Add(TCPClient mtc)
        {
            mtc.room = this;
            mPeopleinroom.Add(mtc);
            mtc.onjoinroom.Invoke(this);
            entrycounter++;
#if MODE1
            ///////////////////
            ///
            FMessagePackage mp = new FMessagePackage();
            mp.MT      = MessageType.EntryMAP;
            mp.PayLoad = roomipaddress;
            String str = JsonConvert.SerializeObject(mp);
            mtc.Send(str);
#endif
            if (pker.runing == false)
            {
                pker.runing = true;
                pker.threadkiller.Start();
            }
            ////////////////////////////
            int len = mPeopleinroom.Count;
            Console.WriteLine("Room :" + len.ToString());
            if (len < maxpeople)
            {
                return(true);
            }
            else
            {
#if MODE1
#else
                Thread mt = new Thread(new ThreadStart(allpeoplepresentjustgo));
                mt.Start();
                Console.WriteLine("allpeoplepresentjustgo :");
#endif
                return(false);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            IPAddress   ipAd   = IPAddress.Parse("192.168.1.240");
            TcpListener myList = new TcpListener(ipAd, 8001);

            /* Start Listeneting at the specified port */
            myList.Start();
            Thread matchalgorithm = new Thread(new ThreadStart(Matchalgorithm));
            Thread matchalhelp    = new Thread(new ThreadStart(singinpooltomatchpool));

            matchalhelp.Start();
            matchalgorithm.Start();
            while (true)
            {
                Socket    st        = myList.AcceptSocket();
                TCPClient tcpClient = new TCPClient(st);
                lock (singinLock)
                {
                    singinpool.Add(tcpClient);
                }
                int len = singinpool.Count;
                Console.WriteLine("singinpool " + len.ToString());
            }
        }