Skip to content

Implement real-time call updates using Redis and Socket.io#5

Open
LuisNoriega2021 wants to merge 12 commits into
development-voycelink:mainfrom
LuisNoriega2021:dev
Open

Implement real-time call updates using Redis and Socket.io#5
LuisNoriega2021 wants to merge 12 commits into
development-voycelink:mainfrom
LuisNoriega2021:dev

Conversation

@LuisNoriega2021
Copy link
Copy Markdown

This PR implements a complete real-time event-driven flow across the system, connecting the backend, Redis, realtime service, and frontend.

Key Features

  • Redis Pub/Sub integration in call-service
  • Realtime event consumption and broadcasting via Socket.io
  • Room-based subscriptions per callId
  • Frontend integration with live updates for calls and events
  • Replacement of mock data with real API calls

Frontend Improvements

  • useCalls now fetches real data and reacts to realtime updates
  • useCallEvents fetches history and listens for live events
  • Socket connection lifecycle handled properly

Backend Improvements

  • Added event publishing to Redis
  • Implemented getCallEvents endpoint
  • Improved validation and state transitions

How to Test

  1. Start all services (Postgres, Redis, backend, realtime, frontend)
  2. Open the dashboard
  3. Send events via Postman:
    • POST /api/events (call_initiated, call_answered, etc.)
  4. Observe real-time updates in the UI

* added processEvent logic in Callservice
* persist calls and call_events in PostgreSQl
* handle call_answwered
* validate call existence before processing events
* update call status from waiting to active on call_answered
* flag events when waitTime exceeds 30s
* persist enriched event metadata in call_events table
* validate call existence before processing events
* update call status to ended
* validate call existence before processing hold events
* update call status to on_hold
* flags events when holdDuration exceeds 60 seconds
* persist enriched metadata in calla_events
* Add support for optional status and queueId filters
* Use parameterized queries to prevent SQL injection or another attack's
* introduce dynamic where clause generation base on provided filters
* add unit tests for CallService  covering core call lifecycle, this for all cases required
* Implements getCallEvents to retrieve ordered event history per call
*Adds and completes unit and integration tests for call lifecycle events
* enforcement, and business rules like answered, hold, ended
* Ensures consistent event persistence
* Added Redis publish integration in CallService
* Standardized event publishing using 'call_events' channel
* Verified real-time event propagation via Redis
* Implement 'subscribe_call' handler to join a specific call room
* Implement 'unsubscribe_call' handler to leave a call room
* Remove naive global io.emit implementation
…cket

* Implement Redis subscriber to listen to 'call_events' channel
* Broadcast updates to clients using Socket.io rooms
* Align Redis channel naming between call-service and realtime-service
* Enable real-time propagation of call lifecycle events to frontend
…ime service

*  Implement Redis Pub/Sub in call-service to publish call events
* Add Redis subscriber in realtime-service to consume events and broadcast via Socket.io
* Replace mock data in frontend with real API integration
* Implement useCallEvents hook with initial fetch and live event streaming
* Ensure backend remains source of truth by using refetch strategy on updates
* Add missing endpoint for fetching call events history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant