refactor: rename trip dispatch socket event to trip offer and update corresponding listener to trip:update

This commit is contained in:
Hamza-Ayed
2026-07-18 22:10:54 +03:00
parent 7a0372b018
commit fe376f8aa6
+5 -5
View File
@@ -73,9 +73,9 @@ async function run() {
driverSocket.on('connect', () => console.log('\x1b[36m[Driver WS] Connected to Gateway\x1b[0m'));
riderSocket.on('connect', () => console.log('\x1b[36m[Rider WS] Connected to Gateway\x1b[0m'));
driverSocket.on('trip:dispatch', async (data) => {
console.log(`\n\x1b[35m[Driver WS] 🔔 RECEIVED DISPATCH for Trip ${data.tripId || data.id}!\x1b[0m`);
console.log(`Dispatch Payload:`, JSON.stringify(data, null, 2));
driverSocket.on('trip:offer', async (data) => {
console.log(`\n\x1b[35m[Driver WS] 🔔 RECEIVED OFFER for Trip ${data.tripId || data.id}!\x1b[0m`);
console.log(`Offer Payload:`, JSON.stringify(data, null, 2));
tripId = data.tripId || data.id;
try {
@@ -87,7 +87,7 @@ async function run() {
}
});
riderSocket.on('trip:updated', (data) => {
riderSocket.on('trip:update', (data) => {
console.log(`\x1b[33m[Rider WS] Trip status updated: ${data.status}\x1b[0m`);
});
@@ -143,7 +143,7 @@ async function run() {
console.error(`\x1b[31m[Simulation Error] ${e.message}\x1b[0m`);
}
} else {
console.log(`\n\x1b[31mFailed to receive dispatch!\x1b[0m`);
console.log(`\n\x1b[31mFailed to receive offer!\x1b[0m`);
console.log(`[Hint] Check if offeredDrivers was 0. If it was 0, the backend didn't find the driver in Redis. If it was > 0, the backend emitted the socket event but the driver didn't receive it.\n`);
}