Comments (4)
Hi @lostncg ,
You don't need another websocket handler for that. There's a special event name disconnect
preserved for disconnect event callback. (not disconnecting
)
The sender will leave all related rooms automatically. So basically you don't need to leave the rooms by yourself. And this action is before calling disconnect
callback, so you are not able to get the room list for current sender.
Thanks a lot for your support! Welcome to open another issue if you still have any questions.
from laravel-swoole.
Hi @lostncg ,
Not sure where did you call Room
facade? I tested it in websocket closure, websocket controller, http route closure and http controller, and it worked fine.
Did you access this page via Swoole server?
from laravel-swoole.
@albertcht , you are right, I access the page on wrong port.
The sender will leave the rooms automatically after disconnect event right?
If yes, how can I do if I need to trigger some function (like remove user from online name list)
like:
Websocket::on('disconnecting', function ($websocket) {
// get disconected user
$fd = $websocket->getSender();
// get user's rooms
$rooms = Room::getRooms($fd);
// loop rooms name
foreach ($rooms as $room) {
// a function to grab room instance implments in adapter design
$channel = $this->getChannel($room, $fd, auth()->user());
// trigger leave room event, like remove user from online list
$channel->leave();
}
});
As I can understand from documentation, I need to implement my own websocket handler right?
BTW, thank for your fast response on anytime, enjoy your 🍺
from laravel-swoole.
Currently, I will store user's room joined in redis table, I think this is the easier implementation by now.
from laravel-swoole.
Related Issues (20)
- WARNING Server::check_worker_exit_status(): worker(pid=690, id=14) abnormal exit, status=0, signal=9
- Routes file changes not picked up until I restart my Docker container HOT 1
- [question] does this support mysql persistent connection or mysql connection pooling HOT 1
- Hot reload not working HOT 2
- Swoole Kill Process Without Waiting For Http Call
- How did I know swoole is succefull applied on my environment HOT 1
- streamDownload not working and sometimes also throw "allowed memory size ... exhausted" HOT 2
- high latency after loop
- can a controller run out swoole HOT 1
- Err in line 8 of tests/fixtures/bootstrap/app.php
- Auth user problem on web socket connection HOT 1
- auth user class redis not fund
- [Question] How to change default base_path so file upload $directory will be default on public folder rather than the root laravel folder? HOT 2
- Socket.io client not work with Websockets implementation out of box
- timer
- 调用chatgpt的流式响应输出有问题 HOT 1
- 为什么在使用websocket服务时,触发on connect回调的时候发送消息给指定userid的人,自己也会收到消息 HOT 1
- facades are not safe to use inside coroutine for sure in this package. HOT 1
- swoole HOT 1
- 响应时间较长的接口出现504或者502,后台程序则依然正常执行
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-swoole.