Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/Server/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function getApplication()

$snapshot = clone $this->application;
$this->resetLaravelApp($snapshot->getApplication());
$this->rebindRouterContainer($snapshot->getApplication());

return $this->snapshot = $snapshot;
}
Expand All @@ -85,6 +84,9 @@ protected function resetLaravelApp($application)
$reflector->setAccessible(true);
$reflector->invoke($application);
}

$this->rebindRouterContainer($application);
$this->rebindViewContainer($application);
}

/**
Expand All @@ -108,6 +110,22 @@ protected function rebindRouterContainer($application)
}
}

/**
* Rebind laravel/lumen's container in view.
*/
protected function rebindViewContainer($application)
{
$view = $application->make('view');

$closure = function () use ($application) {
$this->container = $application;
$this->shared['app'] = $application;
};

$resetView = $closure->bindTo($view, $view);
$resetView();
}

/**
* Get application's framework.
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Websocket/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ public function call(string $event, $data = null)
]);
}

/**
* Close current connection.
*
* @param integer
*/
public function close(int $fd = null)
{
return app('swoole.server')->close($fd ?: $this->sender);
}

/**
* Set sender fd.
*
Expand Down