Example #1
0
            void Accept(RemoteConnection connection)
            {
                var          ch     = (TcpServerChannel)this.channel;
                NativeHandle client = connection.Client;

                if (connection.Error != null)
                {
                    Logger.Warn("Client connection failed.", connection.Error);
                    try
                    {
                        client?.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Logger.Warn("Failed to dispose a client connection.", ex);
                    }

                    return;
                }

                if (client == null)
                {
                    return;
                }

                if (ch.EventLoop is DispatcherEventLoop dispatcher)
                {
                    dispatcher.Dispatch(client);
                }
                else
                {
                    this.Accept((Tcp)client);
                }
            }
Example #2
0
        public void Close()
        {
            if (_isConnected)
            {
                // flush the pipe to allow the client to read the pipe's contents
                // before disconnecting
                PipeNative.FlushFileBuffers(_handle);
                PipeNative.DisconnectNamedPipe(_handle);
            }

            // close handle
            _handle.Dispose();
        }
Example #3
0
            // Connection callback from Libuv thread
            void IServerNativeUnsafe.Accept(RemoteConnection connection)
            {
                var          ch     = _channel;
                NativeHandle client = connection.Client;

                var connError = connection.Error;

                // If the AutoRead is false, reject the connection
                if (!ch._config.AutoRead || connError is object)
                {
                    if (connError is object)
                    {
                        if (Logger.InfoEnabled)
                        {
                            Logger.AcceptClientConnectionFailed(connError);
                        }
                        _ = _channel.Pipeline.FireExceptionCaught(connError);
                    }
                    try
                    {
                        client?.Dispose();
                    }
                    catch (Exception ex)
                    {
                        if (Logger.WarnEnabled)
                        {
                            Logger.FailedToDisposeAClientConnection(ex);
                        }
                    }
                    finally
                    {
                        client = null;
                    }
                }
                if (client is null)
                {
                    return;
                }

                if (ch.EventLoop is DispatcherEventLoop dispatcher)
                {
                    // Dispatch handle to other Libuv loop/thread
                    dispatcher.Dispatch(client);
                }
                else
                {
                    Accept((Tcp)client);
                }
            }
Example #4
0
        /// <summary>
        /// Release this instance from both the managed and unmanaged side.
        /// </summary>
        public void Release()
        {
            var skeleton = NativeHandle?.GetISkeletonAnim();

            if (skeleton != null)
            {
                if (Enum.GetValues(typeof(EMotionParamID)) is int[] values)
                {
                    foreach (var value in values)
                    {
                        skeleton.SetDesiredMotionParam((EMotionParamID)value, 0, 0);
                    }
                }
            }

            NativeHandle?.Dispose();
            // TODO Set self to disposed.
        }
Example #5
0
            // Connection callback from Libuv thread
            void IServerNativeUnsafe.Accept(RemoteConnection connection)
            {
                var          ch     = (TcpServerChannel)this.channel;
                NativeHandle client = connection.Client;

                // If the AutoRead is false, reject the connection
                if (!ch.config.AutoRead || connection.Error != null)
                {
                    if (connection.Error != null)
                    {
                        Logger.Info("Accept client connection failed.", connection.Error);
                    }
                    try
                    {
                        client?.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Logger.Warn("Failed to dispose a client connection.", ex);
                    }
                    finally
                    {
                        client = null;
                    }
                }
                if (client == null)
                {
                    return;
                }

                if (ch.EventLoop is DispatcherEventLoop dispatcher)
                {
                    // Dispatch handle to other Libuv loop/thread
                    dispatcher.Dispatch(client);
                }
                else
                {
                    this.Accept((Tcp)client);
                }
            }
Example #6
0
 /// <summary>
 /// Closes the reference to the object.
 /// </summary>
 public void Dispose()
 {
     _handle.Dispose();
 }