Skip to content

[BE-26] Create WebSocket gateway for real-time asset events in opsce module #751

@yusuftomilola

Description

@yusuftomilola

Problem

The frontend has a useWebSocket hook and socket.io-client installed, but the backend has no WebSocket gateway. Real-time notifications for asset status changes, transfers, and maintenance alerts are not possible.

Proposed Solution

Create backend/src/opsce/notifications/notifications.gateway.ts using @WebSocketGateway from @nestjs/websockets. Emit events from AssetsService and MaintenanceService via @nestjs/event-emitter.

Acceptance Criteria

  • Gateway authenticates WebSocket connections using the JWT from the handshake auth.token
  • Emits asset.updated event with asset ID and changed fields when an asset is updated
  • Emits asset.transferred event when an asset is transferred
  • Emits maintenance.due event when a scheduled maintenance date is within 7 days
  • Users are joined to a room named by their userId on connect
  • Gateway registered in OpsceModule

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions