http-request-manager 18.6.0 → 18.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -422,27 +422,87 @@ This service manages the lifecycle of a WebSocket connection. It handles authent
422
422
  - **Connection Management:** Handles connecting, disconnecting, and reconnecting.
423
423
  - **Authentication:** Supports JWT-based authentication for secure connections.
424
424
  - **Channels:** Allows subscribing and unsubscribing to specific channels.
425
+ - **Channel Management:** Create and delete channels dynamically.
425
426
  - **Messaging:** Supports sending messages to specific channels, users, or broadcasting to all.
426
- - **Observables:** Exposes `messages$` stream and `connectionStatus$` for reactive integration.
427
+ - **Observables:** Exposes `messages$`, `connectionStatus$`, and `subscribedChannels$` for reactive integration.
428
+ - **Session Persistence:** Automatically generates and persists session IDs for reconnection scenarios.
427
429
 
428
430
  **Usage:**
429
431
 
430
432
  ```typescript
431
433
  wsService = inject(WebsocketService);
432
434
 
433
- // Connect
434
- this.wsService.connect('wss://api.example.com/ws', 'jwt-token');
435
+ // Connect with options
436
+ this.wsService.connect({
437
+ id: 'my-primary-channel',
438
+ wsServer: 'wss://api.example.com/ws',
439
+ user: { ldap: 'jdoe', name: 'John Doe' },
440
+ channels: ['PUB-notifications', 'PUB-updates']
441
+ }, 'jwt-token');
435
442
 
436
- // Subscribe to channel
437
- this.wsService.subscribeToChannel('my-channel');
443
+ // Subscribe to additional channels
444
+ this.wsService.subscribeToChannel('PUB-my-channel');
445
+
446
+ // Unsubscribe from a channel
447
+ this.wsService.unsubscribeFromChannel('PUB-my-channel');
438
448
 
439
449
  // Listen to messages
440
450
  this.wsService.messages$.subscribe(msg => console.log(msg));
441
451
 
442
- // Send Message
443
- this.wsService.sendMessageInChannel('my-channel', { text: 'hello' });
452
+ // Send message to a channel
453
+ this.wsService.sendChannelMessage('PUB-my-channel', { text: 'Hello!' });
454
+
455
+ // Track subscribed channels
456
+ this.wsService.subscribedChannels$.subscribe(channels => console.log([...channels]));
457
+
458
+ // Create/Delete channels
459
+ this.wsService.createChannel('PUB-new-channel');
460
+ this.wsService.deleteChannel('PUB-old-channel');
461
+
462
+ // Get all available channels
463
+ this.wsService.getAllChannels();
464
+
465
+ // Get users in a channel
466
+ this.wsService.getUsersInChannel('PUB-my-channel');
444
467
  ```
445
468
 
469
+ #### Channel Naming Conventions
470
+
471
+ The WebSocket service supports channel prefixes for organizing communication:
472
+
473
+ | Prefix | Description | Visibility |
474
+ | :--- | :--- | :--- |
475
+ | `PUB-` | Public channels for user messaging | Visible to users |
476
+ | `SYS-` | System channels for internal communication | Hidden from users |
477
+
478
+ **Example:**
479
+
480
+ ```typescript
481
+ // Create a public channel (visible in UI)
482
+ this.wsService.createChannel('PUB-general-chat');
483
+
484
+ // Create a system channel (hidden from UI)
485
+ this.wsService.createChannel('SYS-internal-notifications');
486
+ ```
487
+
488
+ #### WebSocket Message Types
489
+
490
+ | Type | Description | Direction |
491
+ | :--- | :--- | :--- |
492
+ | `subscribe` | Subscribe to a channel | Client → Server |
493
+ | `unsubscribe` | Unsubscribe from a channel | Client → Server |
494
+ | `message` | Send message to channel subscribers | Client → Server |
495
+ | `broadcast` | Broadcast to all connected clients | Client → Server |
496
+ | `userMessage` | Send message to specific user | Client → Server |
497
+ | `createChannel` | Create a new channel | Client → Server |
498
+ | `deleteChannel` | Delete an existing channel | Client → Server |
499
+ | `getChannels` | Request list of all channels | Client → Server |
500
+ | `getUsers` | Get users in a channel | Client → Server |
501
+ | `channelsList` | List of available channels | Server → Client |
502
+ | `subscribed` | Subscription confirmation | Server → Client |
503
+ | `unsubscribed` | Unsubscription confirmation | Server → Client |
504
+ | `incomingMessage` | Message received in a channel | Server → Client |
505
+
446
506
  #### WebSocket Options (`WSOptions`)
447
507
 
448
508
  | Option | Type | Description | Default |