/**
  * Handle the server was poked event.
  *
  * @param ServerWasPoked $event
  *
  * @return void
  */
 public function handle(ServerWasPoked $event)
 {
     $channel = env('PUSHER_CHANNEL', 'pi-finder');
     $device = $event->getDevice();
     if ($device->isPublic()) {
         $this->pusher->trigger($channel, 'ServerWasPoked', ['device' => $this->transformer->transform($device)]);
     } else {
         $channel = $channel . '-' . $device->group;
         $this->pusher->trigger($channel, 'ServerWasPoked', ['device' => $this->transformer->transform($device)]);
     }
 }
Example #2
0
 /**
  * Handle device pokes.
  *
  * @param StoreComputerRequest $request
  *
  * @throws \Exception
  *
  * @return Response
  */
 public function poke(StoreComputerRequest $request)
 {
     $device = Device::firstOrNew(['mac' => $request->mac]);
     $device->fill($request->all());
     $device->group = $request->get('group', null);
     $device->public = $request->get('public', 'auto');
     $device->touch();
     event(new ServerWasPoked(array_add($device, 'server_time', Carbon::now()->toDateTimeString())));
     return $this->respondPoked($this->transformer->transform($device), $device->id);
 }
Example #3
0
 public function deleted($device)
 {
     $this->pusher->trigger(env('PUSHER_CHANNEL', 'pi-finder'), 'DeviceWasDeleted', ['device' => $this->transformer->transform($device)]);
 }