Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index()
- {
- $servers = Server::all();
- foreach($servers as $server)
- {
- //Job Dispatch
- $job = (new UpdateServer($server->id))->delay(30);
- $this->dispatch($job);
- }
- return view('serverlist.index', compact('servers'));
- }
- class UpdateServer extends Job implements SelfHandling, ShouldQueue
- {
- use InteractsWithQueue, SerializesModels;
- protected $id;
- public function __construct($id)
- {
- $this->id = $id;
- }
- public function handle(){
- $server = Server::findOrFail($this->id);
- //preparing the packet
- $test = new RAGBuffer();
- $test->addChar('255');
- $test->addChar('1');
- $test->addShort(1 | 8);
- //finding the server
- $serverGame = new RAGServer($server->server_ip);
- //Get server info
- $status = $serverGame->sendPacket($test);
- $server->onlinePlayers = $status->getOnline();
- $server->peakPlayers = $status->getPeak();
- $server->maxPlayers = $status->getMax();
- if (!$server->save()) {
- //error ocurred
- }
- }
- }
- APP_ENV=local
- APP_DEBUG=true
- APP_KEY=SomeRandomString
- DB_HOST=localhost
- DB_DATABASE=homestead
- DB_USERNAME=homestead
- DB_PASSWORD=secret
- CACHE_DRIVER=file
- SESSION_DRIVER=file
- QUEUE_DRIVER=sync //< put the desired driver here
- MAIL_DRIVER=smtp
- MAIL_HOST=mailtrap.io
- MAIL_PORT=2525
- MAIL_USERNAME=null
- MAIL_PASSWORD=null
- MAIL_ENCRYPTION=null
- QUEUE_DRIVER=database
- php artisan config:clear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement