Esempio n. 1
0
 protected void Tick(Thread.ContextThread ctx)
 {
     for (int i = 0; i < TickScenes.Count; i++)
     {
         var scene = TickScenes[i];
         if (scene == null)
         {
             continue;
         }
         if (scene.NeedTick == false)
         {
             continue;
         }
         scene.Tick();
     }
 }
Esempio n. 2
0
        public void Init(int id, UInt16 port = 11000)
        {
            mPort        = port;
            mRecvEP      = new IPEndPoint(IPAddress.Any, mPort);
            SendCallBack = new AsyncCallback(this.SendCallback);
            var epRecv = new IPEndPoint(IPAddress.Any, port); //设置服务器端口,IP是本程序所在PC的内网IP
            var epSend = new IPEndPoint(IPAddress.Any, port); //设置客户端,任意IP,任意端口号

            mRecv = new UdpClient(epRecv);                    //绑定设置的服务器端口和IP

            var ctxThread = new Thread.ContextThread();

            ctxThread.StartThread("UdpRecv", (ctx) =>
            {
                IAsyncResult iar = mRecv.BeginReceive(RecvCallBack, null);
                mRecvDone.WaitOne();
            });
            mSend = new UdpClient(epSend);
        }