RideWiseCore Docs

Agent tracking

How agent locations flow in, what each status means, and when an agent goes offline.

Tracking is how RideWiseCore knows where your agents are and who can take a ride. Your backend sends each agent's location over the real-time socket, and RideWiseCore keeps the latest position and status for every agent.

Sending a location

socket.emit(
  "agent:location",
  {
    agentId: "agt_1001",   // your ID for the agent
    lat: 40.7128,
    lng: -74.0060,
    status: "available",    // "available" | "busy" | "offline"
    vehicleType: "sedan",
    heading: 92,            // optional, degrees 0–360
    speed: 11.4,            // optional, your unit (e.g. m/s)
  },
  (ack) => {
    if (!ack.ok) console.error(ack.error);
  },
);

Every location you send:

  1. Updates the agent's stored position, status and vehicle type.
  2. Refreshes the agent's last seen time.
  3. Is sent back to every socket in your room as a agent:update event, so your dashboards and passenger-facing services can show it live.

Agent statuses

StatusMeaningCan receive offers?Counts as active (billing)?
availableOnline and free to take a ride✅ Yes✅ Yes
busyOnline but on a trip or otherwise unavailable❌ No✅ Yes
offlineSigned off❌ No❌ No

Always send status explicitly

If you leave status out, it defaults to available. When an agent accepts a ride, RideWiseCore marks them busy. If your next location update for that agent doesn't include status: "busy", they become available again and can be offered a second ride mid-trip. Always send the agent's real status with every update.

Freshness: the 30-second rule

An agent is considered fresh if RideWiseCore received a location from them in the last 30 seconds.

  • Matching skips any agent who isn't fresh, even if their last status was available.
  • A background sweep runs every ~10 seconds. It takes agents who have gone silent for 30 seconds offline, which removes them from matching and from your active-agent count.

This covers crashed apps, dead batteries and lost signal without any action from you.

Recommended cadence: send a location for every online agent every 3–10 seconds. Sending more often only improves accuracy. You're billed on peak concurrent agents, not on the number of updates, so frequent updates cost nothing extra.

Taking an agent offline

When an agent signs off, send one final update with status: "offline":

socket.emit("agent:location", {
  agentId: "agt_1001",
  lat: 40.7128,
  lng: -74.0060,
  status: "offline",
  vehicleType: "sedan",
});

This takes them out of matching and your active count straight away, instead of waiting 30 seconds.

Trip lifecycle and status

A typical agent's status over a shift:

sign in ──▶ available ──(accepts ride)──▶ busy ──(trip ends)──▶ available ──▶ … ──▶ offline
                        RideWiseCore sets     you send "busy"   you send
                        busy on accept        while on the trip "available"

RideWiseCore has no trip model, so it can't know when a trip ends. Your backend tells it by sending status: "available" again.

Following your live fleet

Listen for agent:update on your socket. Every stored location is echoed there, so you can drive live maps from it.

Validation rules

FieldRule
agentId1–100 chars, letters, numbers, _ and - only
lat−90 to 90
lng−180 to 180
statusavailable, busy or offline (default available)
vehicleType1–50 chars, required
headingOptional, 0–360
speedOptional, ≥ 0

An invalid payload is rejected through the acknowledgement: { ok: false, error: "…" }.

On this page