SDK Reference
Realtime Socket.IO connections for live vehicle positions and Linxio notifications.
Realtime methods use the https://track.linxio.com Socket.IO host by default.
Authenticate first or hydrate the client with an existing token before opening a
socket.
Input namespacecoordinates | notifications
required Realtime namespace to connect to.
Optional JWT token. Defaults to the token stored on the parent client.
Returns Socket.IO client instance for the namespace.
throwsLinxioRealtimeError
optional Thrown when no token is available.
await linxio.auth. login ({ email, password });
const socket = linxio.realtime. connect ( "coordinates" );
socket. on ( "connect" , () => {
console. log ( "connected" );
}); {
"data" : "string"
}
Input vehicleIdsreadonly LinxioId[]
required Vehicles to subscribe to. Values are converted to numbers before sending.
namespacecoordinates | notifications
optional Namespace to subscribe through.
Default: coordinates
Returns dataPromise<LinxioRealtimeSubscribeAck>
optional Acknowledgement from Linxio's subscribe event.
throwsLinxioRealtimeError
optional Thrown when no token is available.
const ack = await linxio.realtime. subscribe ([vehicleId]);
if (ack.error) {
console. error (ack.error);
} {
"data" : "string"
}
Input vehicleIdsreadonly LinxioId[]
required Vehicles to subscribe to.
Function called for each coordinate payload.
Show child parameters Latitude in decimal degrees.
Longitude in decimal degrees.
Telemetry timestamp when supplied by Linxio.
addressstring | null
optional driverIdLinxioId | null
optional headingnumber | null
optional speednumber | null
optional Speed value from Linxio telemetry.
vehicleIdLinxioId
required Returns dataRealtimeUnsubscribe
optional Function that removes listeners for this subscription.
Object field. Expand to see child fields.
Show child fields vehicleIdLinxioId
optional Vehicle identifier in each position payload.
lat / payload.lngnumber
optional speednumber | null
optional Speed when supplied by Linxio.
const unsubscribe = linxio.realtime. onPosition ([vehicleId], ( position ) => {
console. log (position.vehicleId, position.lat, position.lng);
});
process. on ( "SIGINT" , () => {
unsubscribe ();
linxio.realtime. disconnect ( "coordinates" );
}); {
"data" : "string" ,
"payload" : {
"vehicleId" : 64553 ,
"lat / payload" : {
"lng" : 123
} ,
"speed" : 123
}
}
Input handler(notification: LinxioNotification) => void
required Function called for each notification payload.
Returns dataRealtimeUnsubscribe
optional Function that removes notification listeners.
Object field. Expand to see child fields.
Show child fields Notification type when supplied.
Notification message when supplied.
Input Socket event name to listen for.
handler(payload: TPayload) => void
required Function called for each matching event payload.
Returns dataRealtimeUnsubscribe
optional Function that removes the custom event listener.
const unsubscribe = linxio.realtime. onNotificationType (
"vehicle-alert" ,
( payload ) => {
console. log (payload);
},
); {
"data" : "string"
}
Input namespacecoordinates | notifications
optional Namespace to disconnect. Omit to disconnect all active sockets.
Returns disconnect() does not return a value.
linxio.realtime. disconnect ( "coordinates" );
linxio.realtime. disconnect ();