Pulsetracker simplifies real-time location tracking by providing multiple options to listen for updates in both front-end and back-end systems:
Available Integration Methods
-
Pusher-Compatible Server
Pulsetracker offers a server that mimics the functionality of Pusher, making it straightforward to integrate with your existing front-end or back-end listeners.-
Ideal for real-time front-end applications.
-
Compatible with libraries like Laravel Echo, Pusher.js, and others.
-
-
Redis Pub/Sub Server
Pulsetracker also provides a Redis pub/sub server designed for backend listeners.-
Best suited for server-side applications and processing.
-
Highly efficient for scalable backend systems that need to process large volumes of location data in real time.
-
Works well with worker processes to handle updates asynchronously.
-
Integration Examples
-
Backend Listener Using Redis Pub/Sub:
Subscribe to a Redis channel to process location updates and perform server-side operations like logging, geofencing, or analytics. -
Frontend Listener Using Pusher-Compatible Server:
Display real-time updates on maps or dashboards in your web or mobile applications with minimal setup.
The WebSocket server uses the Pusher protocol, and the Redis server uses Redis RESP protocol chosen for its compatibility with a wide range of existing applications. For detailed integration guidelines and additional information, please refer to the official Pusher documentation | Redis documentation.
Pusher configuration
-
Server Address:
pusher.pulsestracker.com
-
Server APP KEY:
92OHYPuG0KB2IPv8
-
Channel Name:
private-apps.YOUR_APP_KEY
-
Event Name:
App\Events\DeviceLocationUpdated
-
Auth endpoint:
https://www.pulsestracker.com/api/broadcasting/auth
-
Auth headers:
Authorization: Bearer <token>
Example using Pusher Javascript SDK
let client = new Pusher('SERVER_APP_KEY', {
wsHost: 'pusher.pulsestracker.com',
wssPort: 443,
forceTLS: true,
disableStats: true,
cluster: "",
enabledTransports: ['wss', 'ws'],
authEndpoint: 'https://www.pulsestracker.com/api/broadcasting/auth',
auth: {
headers: {
Authorization: 'Bearer YOUR_TOKEN',
}
}
});
client.subscribe('private-apps.YOUR_APP_KEY').bind('App\\Events\\DeviceLocationUpdated', (message) => {
console.log(message);
});
Example using Pusher Javascript SDK with laravel echo
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
wsHost: import.meta.env.VITE_PUSHER_HOST,
wssHost: import.meta.env.VITE_PUSHER_HOST,
forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
disableStats: true,
});
Echo.private('apps.YOUR_APP_KEY').listen('DeviceLocationUpdated', (device) => {
// location update
console.log(device);
})
Example event message
{
"event": "App\\Events\\DeviceLocationUpdated",
"channel": "private-apps.APP_KEY",
"data": "{\"appKey\":\"APP_KEY\",\"key\":\"DEVICE_KEY\",\"name\":\"DEVICE_NAME\",\"ip\":\"0.0.0.0\",\"location\":{\"type\":\"Point\",\"coordinates\":[-0.071368,51.5107]}, \"extra\" : {}}"
}
Redis configuration
-
URI:
redis://redis-sub.pulsestracker.com:6378
-
Channel name:
app:{app_key}.{signature}
Example using python
import redis
import hashlib
import hmac
def generate_signature(app_key: str, token: str) -> str:
# Validate token format
if '|' not in token:
raise ValueError('Invalid token format')
# Extract the secret part of the token (after '|')
secret = token.split('|', 1)[1]
# Generate the signature
hashed_secret = hashlib.sha256(secret.encode()).hexdigest()
signature = hmac.new(hashed_secret.encode(), app_key.encode(), hashlib.sha256).hexdigest()
return signature
app_key = "YOUR_APP_KEY"
token = "YOUR_TOKEN"
signature = generate_signature(app_key, token)
channel = f"app:{app_key}.{signature}"
redis_client = redis.from_url("redis://redis-sub.pulsestracker.com:6378")
pubsub = redis_client.pubsub()
pubsub.subscribe(channel)
print(f"Subscribed to {channel}. Waiting for messages...")
for message in pubsub.listen():
if message['type'] == 'message':
print(f"Received: {message['data'].decode('utf-8')}")
Example using Laravel
<?php
namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Str;
class PulsetrackerSubscribe extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pulsetracker:subscribe';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Subscribe to pulsetracker redis server and get real time location updates';
/**
* Execute the console command.
*/
public function handle()
{
$appKey = 'YOUR_APP_KEY';
$token = 'YOUR_TOKEN';
$signature = $this->generateSignature($appKey, $token);
// Add this to config/database.php
// 'redis' => [
// 'pulsetracker' => [
// 'url' => env('PULSETRACKER_REDIS_URI')
// ],
// ]
Redis::connection('pulsetracker')->subscribe(["app:$appKey.$signature"], function (string $message) {
echo $message . "\n";
});
}
public function generateSignature(string $appKey, string $token): string
{
if (! str_contains($token, '|')) {
throw new Exception('Invalid token format');
}
return hash_hmac('sha256', $appKey, hash('sha256', Str::after($token, '|')));
}
}