private function trace(string $type): \Closure
    {
        $trace = function() use ($type) {
            switch ($type) {
                case TraceableNetwork::TYPE_DATA:
                    $this->traceData(func_get_args(), $type);
                    break;
                case TraceableNetwork::TYPE_CONNECT:
                case TraceableNetwork::TYPE_DISCONNECT:
                    $this->traceAction(func_get_args(), $type);
                    break;
            }
        };

        return $trace->bindTo($this);
    }