locationServerUrl = config('intaleq.location_server_url'); $this->rideSocketUrl = config('intaleq.ride_socket_url'); $keyPath = config('intaleq.internal_socket_key_path'); $this->internalKey = file_exists($keyPath) ? trim(file_get_contents($keyPath)) : ''; } /** * Notify passenger via ride socket server */ public function notifyPassenger(string $passengerId, array $payload): void { $this->sendAsync($this->rideSocketUrl, array_merge($payload, [ 'action' => 'notify_passenger', 'passenger_id' => $passengerId, ])); } /** * Send event to location server (e.g., ride_taken, cancel_ride) */ public function sendToLocationServer(string $event, array $data): void { $this->sendAsync($this->locationServerUrl, array_merge($data, [ 'action' => $event, ])); } /** * Non-blocking HTTP POST (fire and forget with short timeout) */ private function sendAsync(string $url, array $data): void { try { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($data), CURLOPT_TIMEOUT_MS => 500, CURLOPT_NOSIGNAL => 1, ]); if ($this->internalKey) { curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-internal-key: {$this->internalKey}"]); } curl_exec($ch); curl_close($ch); } catch (\Exception $e) { Log::warning("[Socket] Failed to send to {$url}: " . $e->getMessage()); } } }