feat(streaming): add global activity watchers, client-side buffering, and improved real-time streaming UX

This commit is contained in:
2026-01-28 14:02:48 +00:00
parent ad8529cb0f
commit 8cc9a1850a
14 changed files with 630 additions and 146 deletions

View File

@@ -106,6 +106,28 @@ IReq_PushS3Change: { event: IS3ChangeEvent } -> { received }
IReq_PushActivityEvent: { event: IActivityEvent } -> { received }
```
### WebSocket Context Pattern
When a TypedHandler receives a WebSocket request, the transport context is available via the second argument (`TypedTools` instance). SmartServe attaches the WebSocket peer to `localData.peer`:
```typescript
// In a TypedHandler callback:
async (reqData, context) => {
// context is a TypedTools instance
const peerId = context.localData?.peer?.id; // unique WebSocket connection ID
}
```
To push events back to a specific client, use `findTargetConnection`:
```typescript
const conn = await typedSocket.findTargetConnection(async (c: any) => {
return c.peer?.id === connectionId;
});
const request = typedSocket.createTypedRequest<IReq_Push>('pushEvent', conn);
await request.fire({ event });
```
### Dependencies Added
- `@api.global/typedsocket` - WebSocket client/server