laravel-rabbitmq/producer/app/Console/Commands/SendSocket.php

41 lines
834 B
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SendSocket extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send-socket {username} {message?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$client = new \WebSocket\Client("ws://192.168.56.101:2346/");
$client->text(
json_encode([
'username' => $this->argument('username'),
])
);
$client->text($this->argument('message'));
$client->receive();
$client->close();
}
}