Unique connections (by Session->get('username') )

80 views
Skip to first unread message

Fedot Serghei

unread,
Feb 27, 2015, 8:56:56 AM2/27/15
to ratch...@googlegroups.com
Hello! How i can create a new unique connections?

At this moment I have 

$this->clients->attach($conn); onOpen 
$conn->Session->get('user_id');

I want to count all users connected to my websocket server...(in this moment if i open a new Tab i get a new connection with same account so there is duplicates)

Thank you!

cboden

unread,
May 16, 2015, 12:50:32 AM5/16/15
to ratch...@googlegroups.com, fedo...@gmail.com
If you're using the SessionProvider module you could use a unique user ID if you store that in the session. Alternatively you could use a unique cookie value passed in the HTTP request. Once you have the unique ID from one of those two sources you could use an associative array instead of an SplObjectStorage to keep a lookup of the open connections. 

Federico Fausto Santoro

unread,
Jun 13, 2015, 8:28:05 AM6/13/15
to ratch...@googlegroups.com, fedo...@gmail.com
SplObjectStorage or Array (hash map) ? What is the best choice? 
Reply all
Reply to author
Forward
0 new messages