简体   繁体   中英

Swoole WebSocket Server - communication between client

I'm trying to understand how are we supposed to manage client in Swoole Websocket Server.

I've MyServer who extends from Swoole\WebSocket\Server, I store in a property the client list, but it seems every single client can only see his own list (with only him in it). So if the client 1 send a message who have to be resent to the client 2, the only I've found is to use the getClientList method and send the message to all clients.

But I want also to "bind" clients between themselves... Like 1 with 2 only, 3 with 4 a,nd 5 etc.

I use APCu (forced to CLI mode) to communicate client list to all my client, but it seems I've some multi acces problems now.

Isnt a "native" way in Swoole Websocket Server to store information on my client, information who could by read from any client?

After some more research, I found that Swoole provide a nice build-in class to manage session interaction: Swoole/Table

It's a fast "SQL like" memory management system that allow you to easily communicate between sessions, specifically usefull for websockets session!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM