core/services/socket/ — Socket.IO Service

Manage a Socket.IO WebSocket connection with JWT-authenticated rooms for Flutter.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Vantoan252003/Mozi --skill core-services-socket-socket-io-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: core/services/socket/ — Socket.IO Service
Source: https://github.com/Vantoan252003/Mozi/tree/main/lib/core/services/socket
Command: npx skills add https://github.com/Vantoan252003/Mozi --skill core-services-socket-socket-io-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill centralizes management of a single Socket.IO WebSocket connection for the Flutter client, preventing duplicated connections and simplifying real-time order tracking and event handling across the app.

Core Features & Use Cases

  • Singleton lifecycle management: maintain one global socket, connect on login and disconnect on logout.
  • Authenticated handshake & reconnection: perform JWT-authenticated handshake with Authorization headers and automatic reconnection with configured attempts and delay.
  • Room management & typed event streams: join and leave per-order rooms, emit events, and expose broadcast streams with typed parsers plus a convenience Map parser.
  • Use Case: A TrackingBloc joins an order room, subscribes to driverLocation and orderStatusChange streams filtered by orderId, and updates UI state in real time.

Quick Start

Use the socket service to connect with the user's JWT, join the room for a given orderId and orderType, and subscribe to driverLocation and orderStatusChange events filtered for that order.

Frequently Asked Questions about core/services/socket/ — Socket.IO Service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage a single Socket.IO connection in Flutter to prevent duplicate sockets?

Manage a single Socket.IO connection in Flutter by using a singleton service that connects on login and disconnects on logout, ensuring one global socket instance prevents duplicated connections across the app.

How do I authenticate a Socket.IO handshake with JWT headers in a Flutter app?

Authenticate a Socket.IO handshake in Flutter by passing JWT tokens via Authorization headers during the connection setup, ensuring the server validates the user identity before establishing the WebSocket connection.

How do I join per-order rooms and subscribe to real-time event streams in Flutter?

Join per-order rooms by emitting join events with orderId and orderType, then subscribe to broadcast streams for driverLocation and orderStatusChange events filtered by orderId to receive real-time updates.

Can I use a singleton WebSocket service for ride-hailing and delivery tracking in Flutter?

Yes, a singleton WebSocket service fits ride-hailing and delivery scenarios in Flutter where TrackingBloc components need authenticated per-order rooms for real-time driver location and order status updates.

What reconnection policy applies when a Socket.IO connection drops in Flutter?

The reconnection policy applies a maximum of 5 attempts with a 2-second delay between retries, ensuring the single Socket.IO connection automatically recovers from transient network failures in the Flutter client.