49 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Jobs;
 | |
| 
 | |
| use Illuminate\Bus\Queueable;
 | |
| use Illuminate\Contracts\Queue\ShouldQueue;
 | |
| use Illuminate\Foundation\Bus\Dispatchable;
 | |
| use Illuminate\Queue\InteractsWithQueue;
 | |
| use Illuminate\Queue\SerializesModels;
 | |
| use Illuminate\Support\Facades\Artisan;
 | |
| 
 | |
| class ProcessJob implements ShouldQueue
 | |
| {
 | |
|     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | |
| 
 | |
|     protected $process;
 | |
|     /**
 | |
|      * Create a new job instance.
 | |
|      *
 | |
|      * @return void
 | |
|      */
 | |
|     public function __construct()
 | |
|     {
 | |
|         $process = 'process' . rand(1, 3);
 | |
|         $this->process = $process;
 | |
|         $this->onQueue($process);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Execute the job.
 | |
|      *
 | |
|      * @return void
 | |
|      */
 | |
|     public function handle()
 | |
|     {
 | |
|         $client = new \WebSocket\Client("ws://192.168.56.101:2346/");
 | |
|         $client->text(
 | |
|             json_encode([
 | |
|                 'username' => 'kai.1',
 | |
|             ])
 | |
|         );
 | |
|         $client->text(
 | |
|             $this->process . ': ' . rand()
 | |
|         );
 | |
|         $client->receive();
 | |
|         $client->close();
 | |
|     }
 | |
| }
 |