Comments (10)
ok 谢谢
from laravel-swoole.
Hi @junshenshi ,
請問您的編號 1
是發送者的 fd 嗎?如果是的話 Websocket::broadcast()->to(1)
是無法送達的,因為 broadcast
代表要送給除了自己以外的人
from laravel-swoole.
hai Albert
不是发送给自身,
同样是发送给$to
只有原生方法成功
截图体现了to方法不行
from laravel-swoole.
Hi @junshenshi ,
我的意思是你無法發送的狀況下發送者 fd
和接收者 fd
是相同的嗎?
當發送者 fd
和接收者 fd
相同時又使用了 broadcast 該筆發送會被忽略
再和你確認一次:
Websocket::to(1)->emit('message', 'for your eyes only');
你上面這樣寫是可以發送的嗎?
我剛剛自己測試了一下,發送邏輯是正常的
from laravel-swoole.
发现原因,to()方法需要传整型,字符串的fd无法触发。
from laravel-swoole.
沒錯,to()
方法的參數當傳入整數會被判斷為 fd
,字串會被判斷為房間名稱
這樣的設計是延用自 socket.io
的設計方式
但對於字串型別的 fd
我可能要考慮下該如何兼容
from laravel-swoole.
OK 好了,我强制转换了。考虑下要不要把发送方法to切分为fd发送,room发送两个方法,fd发送可以传数组,因为有个场景大概是同一个用户,打开多个窗口拥有多个fd。我用循环解决了多fd,如果能传数组那更好了。
from laravel-swoole.
其實 websocket 現有的 api 除了有 to
之外,另外有 toAll
的方法是支援 array 的
但我現在可能會想將 toAll
合併至 to
讓他同時支援單或多個 fd
傳入
關於 to
是否會分成兩個方法來區分房間和 fd
我會仔細考慮一下,感謝你的建議
from laravel-swoole.
Ok 谢谢
from laravel-swoole.
Hi @junshenshi ,
在新版的程式中我已經將 websocket 和 room 中原本含有 All
名稱的方法全數移除,並讓原先單數的方法支援單個或是陣列參數
至於 to
我還是照原先的設計同時支援 fd
和房間名稱,只是對於 fd
的形態做更好的兼容,當字串形態的 fd
找不到房間成員時,而 fd
又符合 numeric
條件會將該 fd
列入發送清單中
from laravel-swoole.
Related Issues (20)
- Hello, since the installation , mysql often reports an error. Why is this?
- 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
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.