Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 1f99346

Browse files
authored
Merge pull request #499 from netdown/patch-1
Websocket - Sandbox missing for disconnect event
2 parents e96b46f + 153d7ae commit 1f99346

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Concerns/InteractsWithWebsocket.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,14 @@ public function onClose($server, $fd, $reactorId)
161161
}
162162

163163
$websocket = $this->app->make(Websocket::class);
164+
$sandbox = $this->app->make(Sandbox::class);
164165

165166
try {
166167
$websocket->reset(true)->setSender($fd);
168+
169+
// enable sandbox
170+
$sandbox->enable();
171+
167172
// trigger 'disconnect' websocket event
168173
if ($websocket->eventExists('disconnect')) {
169174
$websocket->call('disconnect');
@@ -174,6 +179,9 @@ public function onClose($server, $fd, $reactorId)
174179
$websocket->leave();
175180
} catch (Throwable $e) {
176181
$this->logServerError($e);
182+
} finally {
183+
// disable and recycle sandbox resource
184+
$sandbox->disable();
177185
}
178186
}
179187

0 commit comments

Comments
 (0)