Exemplo n.º 1
0
 public void ReadStop()
 {
     if (!_GCHandle.IsAllocated)
     {
         return;
     }
     LibUv.ReadStop(this);
     LibUv.BufferStruct bufferStruct = LibUv.CreateBufferStruct(IntPtr.Zero, 0);
     UbReadCb(handle, 0, ref bufferStruct);
 }
Exemplo n.º 2
0
        /// <summary>
        /// libuv read 读取 分配内存的回调函数
        /// </summary>
        /// <param name="intPtr">ClientHandle的指针</param>
        /// <param name="suggestedSize">请求内存大小</param>
        /// <param name="buffer"></param>
        private static void Alloc_Callback(IntPtr intPtr, int suggestedSize, out LibUv.BufferStruct buffer)
        {
            UvStreamHandle uvStreamHandle = GetObjectFromHandel <UvStreamHandle>(intPtr);

            try
            {
                buffer = uvStreamHandle._allocCallback(uvStreamHandle, suggestedSize, uvStreamHandle._readState);
            }
            catch (Exception)
            {
                buffer = uvStreamHandle.LibUv.CreateBufferStruct(IntPtr.Zero, 0);
                throw;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="intPtr"></param>
        /// <param name="num"></param>
        /// <param name="ptr"></param>
        private static void UbReadCb(IntPtr intPtr, int num, ref LibUv.BufferStruct ptr)
        {
            UvStreamHandle uvStreamHandle = GetObjectFromHandel <UvStreamHandle>(intPtr);

            try
            {
                if (num < 0)
                {
                    Exception arg;
                    uvStreamHandle.LibUv.GetException(num, out arg);
                    uvStreamHandle._readCallback(uvStreamHandle, 0, arg, uvStreamHandle._readState);
                }
                else
                {
                    uvStreamHandle._readCallback(uvStreamHandle, num, null, uvStreamHandle._readState);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(">>> DEBUG: OwinDog.LibuvApi.UvStreamHandle.UbReadCb: Call UvSocket  function error:");
                Console.WriteLine(ex.ToString());
            }
        }