Beispiel #1
0
        //打包请求命令帧
        public void BunchRequestCmd(int startFrame, int frameLength, IPEndPoint remote, Action <Request, byte[]> succeed, Action <Request> failed)
        {
            RequestCmdHandle handle = RequestCmdHandle.Instance(startFrame, frameLength, RandVerify);

            //监听请求
            BunchRequestAdd(handle, remote, succeed, failed);
            //Debug.Log("发送请求");
            BunchSend();
        }
Beispiel #2
0
        public static RequestCmdHandle Instance(int startFrame, int frameLength, int verify, byte[] data = null)
        {
            RequestCmdHandle handle = new RequestCmdHandle(null);

            handle.verify      = verify;
            handle.startFrame  = startFrame;
            handle.frameLength = frameLength;
            handle.data        = data;
            return(handle);
        }
Beispiel #3
0
        public void SingleRequestCmd(int startFrame, int frameLength, IPEndPoint remote, Action <Request, byte[]> succeed, Action <Request> failed)
        {
            RequestCmdHandle handle  = RequestCmdHandle.Instance(startFrame, frameLength, 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 + "[RequestCmdHandle]");
            //HandleManager.OutStr += "单独发送" + handle.verify + "数据请求至" + remote + "[RequestCmdHandle]" + "\n";
        }