Beispiel #1
0
        /// <summary>
        /// 这里开始数据接收
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="close"></param>
        public void StartReciveData(Socket socket, Action close = null)
        {
            try
            {
                // 初始化赋值
                mSocket           = socket;
                OnDisReciveEvent += close;

                //回调开启连接事件
                OnStartRecive();
                OnStartReciveEvent?.Invoke();
                //首先是接收头4个字节确认包长
                //4可能太小了
                mKGNetPacket.PacketBuff = new byte[4];
                mSocket.BeginReceive(mKGNetPacket.PacketBuff, 0, 4, SocketFlags.None, ReciveHeadData, null);
            }
            catch (Exception e)
            {
                ("StartReciveDataError:" + e).KLog(LogLevel.Err);
            }
        }
Beispiel #2
0
 protected virtual void OnStartRecive()
 {
     OnStartReciveEvent?.Invoke();
     ("开始了一个连接:").KLog();
 }