Advertisement
Guest User

Untitled

a guest
Mar 25th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public function index()
  2. {
  3. $servers = Server::all();
  4.  
  5. foreach($servers as $server)
  6. {
  7. //Job Dispatch
  8. $job = (new UpdateServer($server->id))->delay(30);
  9. $this->dispatch($job);
  10. }
  11. return view('serverlist.index', compact('servers'));
  12. }
  13.  
  14. class UpdateServer extends Job implements SelfHandling, ShouldQueue
  15. {
  16. use InteractsWithQueue, SerializesModels;
  17. protected $id;
  18.  
  19. public function __construct($id)
  20. {
  21. $this->id = $id;
  22. }
  23.  
  24. public function handle(){
  25. $server = Server::findOrFail($this->id);
  26.  
  27. //preparing the packet
  28. $test = new RAGBuffer();
  29. $test->addChar('255');
  30. $test->addChar('1');
  31. $test->addShort(1 | 8);
  32.  
  33. //finding the server
  34. $serverGame = new RAGServer($server->server_ip);
  35.  
  36. //Get server info
  37. $status = $serverGame->sendPacket($test);
  38.  
  39. $server->onlinePlayers = $status->getOnline();
  40. $server->peakPlayers = $status->getPeak();
  41. $server->maxPlayers = $status->getMax();
  42.  
  43. if (!$server->save()) {
  44. //error ocurred
  45. }
  46. }
  47. }
  48.  
  49. APP_ENV=local
  50. APP_DEBUG=true
  51. APP_KEY=SomeRandomString
  52.  
  53. DB_HOST=localhost
  54. DB_DATABASE=homestead
  55. DB_USERNAME=homestead
  56. DB_PASSWORD=secret
  57.  
  58. CACHE_DRIVER=file
  59. SESSION_DRIVER=file
  60. QUEUE_DRIVER=sync //< put the desired driver here
  61.  
  62. MAIL_DRIVER=smtp
  63. MAIL_HOST=mailtrap.io
  64. MAIL_PORT=2525
  65. MAIL_USERNAME=null
  66. MAIL_PASSWORD=null
  67. MAIL_ENCRYPTION=null
  68.  
  69. QUEUE_DRIVER=database
  70.  
  71. php artisan config:clear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement