Ejemplo n.º 1
0
        public void OnRecv(object target, SocketAsyncEventArgs e)
        {
            IOSocket io = new IOSocket(e.Buffer);

            io.Seek(0);
            int itype = io.ReadInt32();

            switch (itype)
            {
            case NetMsgDefine.HeadBeat:     // 心跳包
            {
                byte b = io.ReadByte();
                lastrecvTime = Environment.TickCount;
                Console.WriteLine("这是心跳包,收到了服务器发来的回复{0}", b);
            }

            break;

            case NetMsgDefine.sayhello:
            {
                string str = io.ReadString8();
                Console.WriteLine(str);
            }
            break;

            case NetMsgDefine.GameLogic:     // 游戏逻辑

                break;

            default:
                break;
            }



            Recv();
        }