예제 #1
0
        void InitManager(UDPHandle <T> handle)
        {
            handleObject = handle;
            handleObject.Log("用户:" + ID);
            //ResendMsg = new Queue<DataTransfer<T>>();
            reciveThread = new Thread(ReciveFunc);
            reciveThread.IsBackground = true;
            reciveThread.Start();

            sendThread = new Thread(SendFunc);
            sendThread.IsBackground = true;
            sendThread.Start();
        }
예제 #2
0
        public override void HandleReceived(byte[] data, IPEndPoint endPoint)
        {
            var reader = new PacketReader(data, 0);

            reader.ReadByte();
            reader.ReadByte();
            short opcode = reader.ReadLEInt16();

            //Console.WriteLine(Utility.ByteArrayToString(data));
            //Console.WriteLine(endPoint.Address.ToString());
            //Console.WriteLine(endPoint.Port);

            /*var handler = DelegateList.LHandlers[opcode];
             * if (handler != null)
             *  handler.OnReceive(this, reader);
             * else
             *  Log.Info("Received Undefined Packet 0x{0:x2}", opcode);*/
            switch (opcode)
            {
            case 0x3D4:
                // AgentServerHandle.Handle_RelayRegisterResult(this, reader);
                UDPHandle.Handle_Connect_04FFD403(this, reader, endPoint);
                break;

            case 0x3D8:
                UDPHandle.Handle_Connect_04FFD803(this, reader, endPoint);
                break;

            case 0x3D6:
                UDPHandle.Handle_ConnectUser_04FFD603(this, reader, endPoint);
                break;

            default:
                break;
            }
        }
예제 #3
0
 public UDPManager(string groupIP, int port, UDPHandle <T> handle)
 {
     groupAddress = IPAddress.Parse(groupIP);
     tport        = port;
     InitManager(handle);
 }