Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass user_id to the server when connecting. #956

Open
ExchangeAssets opened this issue Sep 29, 2023 · 2 comments
Open

Pass user_id to the server when connecting. #956

ExchangeAssets opened this issue Sep 29, 2023 · 2 comments

Comments

@ExchangeAssets
Copy link

Is there a way on the client side to transfer user_id (user ID registered on the site) and referrer (address of the page from which the connection was made) to the server, so that each connection can be checked for user_id and referrer?

@ExchangeAssets
Copy link
Author

ExchangeAssets commented Sep 29, 2023

I use:
$channel_server = new Channel\Server('0.0.0.0', 2347);

it sends messages to all users, as if I need to send messages only to users who are connected from the page mysite.com/page_1, while not sending messages to users connected from mysite.com/page_2.

It should roughly look like this:

foreach($worker->connections as $connection) {
    if($connection->get('page') != 'page_1') continue;
    $connection->send($data);
}

but how to pass 'page' in $connection when connecting? Do you have an example?

@walkor
Copy link
Owner

walkor commented Oct 5, 2023

Just use $connection->page;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants