/** * Handle the event. * * @param FootballMatchUpdated $event * @return mixed */ public function handle(FootballMatchUpdated $event) { if ($event->match) { $match = $this->api->live(); $this->pusher->trigger('live-match', 'new-match', ['match' => $match->getData()]); } }
/** * Generate Pusher authentication token for currently logged user. * * @param Request $request * @param PusherManager $pusher * * @return string */ public function authenticatePusher(Request $request, PusherManager $pusher) { $channelName = 'private-u-' . auth()->id(); $socketId = $request->input('socket_id'); $pusher->connection(); return $pusher->socket_auth($channelName, $socketId); }
/** * 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)]); } }
public function deleted($device) { $this->pusher->trigger(env('PUSHER_CHANNEL', 'pi-finder'), 'DeviceWasDeleted', ['device' => $this->transformer->transform($device)]); }
public function changeTrack(Request $request) { if (isset($request->id)) { $this->pusher->trigger('playlist-channel', 'track-changed', ['id' => $request->id]); } }
public function push(PusherManager $pusher) { $message = 'Hello world' + rand(0, 1000); $pusher->trigger('test-channel', 'new-message', ['message' => $message]); }