Ejemplo n.º 1
0
        //打包请求读取远端数据
        public void BunchRequestBuffer(BufferEnum read, IPEndPoint remote, Action <Request, byte[]> succeed, Action <Request> failed)
        {
            ReadBufferHandle handle = ReadBufferHandle.Instance(read, RandVerify);

            //监听请求
            BunchRequestAdd(handle, remote, succeed, failed);
            //Debug.Log("发送请求");
            BunchSend();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 请求读取远端数据,返回一条操作
        /// 需要指定读取的数据缓存区和远端网络地址
        /// 返回的数据会缓存在回调函数的参数里
        /// </summary>
        public void SingleRequestBuffer(BufferEnum read, IPEndPoint remote, Action <Request, byte[]> succeed, Action <Request> failed)
        {
            ReadBufferHandle handle  = ReadBufferHandle.Instance(read, RandVerify);
            Request          request = new Request(handle, remote, succeed, failed);

            request.isSend    = false;
            request.overtime  = 1000 / FRAME;
            request.timeSend  = TickTime;
            request.timeStart = TickTime;
            request.verify    = handle.verify;

            //添加请求列表
            if (RequestDic.TryAdd(handle.verify, request))
            {
                Netstat netstat = NetstatDic.GetOrAdd(remote, new Netstat());
                netstat.request += 1;
                //注册完成后直接发送
                SendTo(handle.ToBytes(), remote, request);
                //Debug.Log("[注册验证]" + request.verify + "[验证总数]" + RequestDic.Count);
            }
            //Console.WriteLine("单独发送数据请求"+remote + "[ReadBufferHandle]");
            //HandleManager.OutStr += "单独发送" + handle.verify + "数据请求至" + remote + "[ReadBufferHandle]" + "\n";
        }