Overview
What this package owns in the runtime
Socket.IO integrates realtime messaging into xtaskjs without leaving the framework's DI and lifecycle model. It discovers decorated gateway services, attaches to the live HTTP server during app.listen(), exposes namespaces and broadcast helpers through DI, and tears down cleanly during app.close().
What it provides
- SocketGateway(), OnSocketConnection(), OnSocketDisconnect(), and OnSocketEvent() declare realtime handlers on regular @Service() classes.
- Returned values are sent through Socket.IO acknowledgements automatically when the client provides an ack callback.
- InjectSocketService(), InjectSocketServer(), InjectSocketNamespace(), and InjectSocketLifecycleManager() expose the runtime through DI.
- SocketIoService can broadcast events, list gateways, inspect namespaces, and reuse the lifecycle-managed Socket.IO server.
How it fits
- Initialized automatically by @xtaskjs/core when the package is installed and the app starts listening on an HTTP adapter.
- Attaches to the live server behind node-http, Express, or Fastify without changing controller or service registration patterns.
- Demonstrated by the 23-socket_io_express_app sample with room joins, acknowledgements, and HTTP-triggered announcements.