Closed YnievesDotNet closed 9 years ago
Hello :-),
To be frank, I didn't understand your questions.
I understand there is 2 questions.
In this moment I can manage the running of server from Laravel using Artisan command…
Good \o/!
… but I need vinculate one or some nodes for each client, when the client connect at the system.
What “vinculate” means?
what I need is configure the listeners on one abstract class, but inside the server connection, while it is running
This is a PHP related question, and no, it's not possible to change the parent class of an instance. So maybe it is better to expose/explain your workflow instead.
doing this action without Hoa\Websocket\Client and/or Hoa\Socket\Client
You want to write a helper? Just write a function or a trait to connect a client, send a data and close the client.
Hello, thanks.
Vinculate means assign one system user a one or more node in the servers.
For example, if I need send one message at one specific client connected at the system, ex, admin user logged at the laravel system, know wath is yours nodes in the server.
Thanks.
User::id (1) = Node::id (asdasdqwe)
I have try other things, and in this moment, I have one database table with this relations, and I can get all nodes ID for one client.
Now, I want send one message at one node, from my client in php, using websocket/client php library, for example, doing this:
$fstck = FSTocken::where('user_id', 1)->first();
$client = new WsClient(
new SClient('tcp://127.0.0.1:8080')
);
$client->connect();
$client->send('Login rendered', *************);
$client->close();
How I can define this line for correct function. The node ID is in $fstck->websocket_id
.
Thanks.
It's that possible?
How I can connect at one node specific?
Thanks. YnievesDotNet
Hello,
I try to understand on IRC but i really need to go to sleep :D (Paris timezone power)
You want to send an data to an specific node $data = 'hello world';
So you need to have an identifier in your custom node i assume its the method getMyIdentifier
.
You need to do an loop on all your node for find the specific node you will get something like that :
$server->on('message', function (Hoa\Core\Event\Bucket $bucket) {
$nodes = $bucket->getSource()->getConnection()->getNodes();
$data = 'hello world';
foreach($nodes as $node) {
if($node->getID() === 'myID') {
$this->send($data, $node);
}
}
return;
});
You need to test this i write that just for exemple its not probably the solution but maybe a clue
We also have the broadcastIf
method (https://github.com/hoaproject/Socket/blob/8c57600d21582b7b4256590de6830839ac4555f1/Connection/Handler.php#L313-L341). But we opened an issue to document it (see #38), as @camael24 noticed.
Injecting data at the WebSocket/Node object
Hello, I try including this library at my project in Laravel. In this moment I can manage the running of server from Laravel using Artisan command, but I need vinculate one or some nodes for each client, when the client connect at the system.
Other things what I need is configure the listeners on one abstract class, but inside the server connection, while it is running. For example, I need create one class calling HoaWebSocket, and I can configure for example, this:
This is a fictitious idea, is only for comment the flow with I need.
In this moment, I can send the system message at our user using this method
And the idea final is it:
But, doing this action without
Hoa\Websocket\Client
and/orHoa\Socket\Client
.Thanks
YnievesDotNet