@casual-simulation/aux-websocket 3.8.2-alpha.19511653187 → 3.10.2

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.
Files changed (2) hide show
  1. package/README.md +89 -2
  2. package/package.json +43 -44
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # AUX Websocket
1
+ # @casual-simulation/aux-websocket
2
2
 
3
- Websocket integration with AUX services
3
+ WebSocket integration layer for CasualOS (AUX) services, providing a high-level client for real-time communication with AUX servers.
4
+
5
+ ## Overview
6
+
7
+ This package provides a WebSocket-based connection client specifically designed for communicating with CasualOS (AUX) services. It builds on top of `@casual-simulation/websocket` to provide a protocol-aware client with automatic message serialization, event filtering, and connection state management.
8
+
9
+ ## Main Export
10
+
11
+ ### `WebsocketConnectionClient`
12
+
13
+ A WebSocket client implementation that conforms to the `ConnectionClient` interface from `@casual-simulation/aux-common`. It provides structured communication with AUX services using a standardized message protocol.
14
+
15
+ **Features:**
16
+
17
+ - **Protocol-Aware**: Implements the AUX WebSocket message protocol with automatic JSON serialization
18
+ - **Event Filtering**: Subscribe to specific event types using the `event()` method
19
+ - **Connection State Management**: Track connection status via RxJS observables
20
+ - **Error Handling**: Dedicated error stream for handling connection and protocol errors
21
+ - **Request Tracking**: Automatic request ID assignment for message correlation
22
+ - **Type-Safe**: Built with TypeScript for full type safety
23
+
24
+ **Key Methods:**
25
+
26
+ - `connect()` - Establish WebSocket connection
27
+ - `disconnect()` - Close WebSocket connection
28
+ - `send(message)` - Send a message to the server
29
+ - `event<T>(name)` - Subscribe to specific event types
30
+ - `connectionState` - Observable of connection state changes
31
+ - `onError` - Observable of error events
32
+
33
+ **Usage:**
34
+
35
+ ```typescript
36
+ import { WebsocketConnectionClient } from '@casual-simulation/aux-websocket';
37
+ import { ReconnectableSocket } from '@casual-simulation/websocket';
38
+
39
+ // Create underlying WebSocket
40
+ const socket = new ReconnectableSocket('wss://example.com/api/ws');
41
+
42
+ // Create AUX WebSocket client
43
+ const client = new WebsocketConnectionClient(socket);
44
+
45
+ // Listen for connection state changes
46
+ client.connectionState.subscribe((state) => {
47
+ console.log('Connected:', state.connected);
48
+ });
49
+
50
+ // Listen for specific event types
51
+ client.event('device').subscribe((event) => {
52
+ console.log('Device event:', event);
53
+ });
54
+
55
+ // Handle errors
56
+ client.onError.subscribe((error) => {
57
+ console.error('WebSocket error:', error);
58
+ });
59
+
60
+ // Connect and send messages
61
+ client.connect();
62
+ client.send({
63
+ type: 'login',
64
+ // ... message payload
65
+ });
66
+ ```
67
+
68
+ ## Message Protocol
69
+
70
+ The client uses a standardized message format:
71
+
72
+ ```typescript
73
+ [eventType: string, requestId: number, message: WebsocketMessage]
74
+ ```
75
+
76
+ - **eventType**: Type of the WebSocket event (e.g., 'message', 'error')
77
+ - **requestId**: Auto-incrementing request identifier
78
+ - **message**: The actual message payload
79
+
80
+ ## Dependencies
81
+
82
+ - **@casual-simulation/websocket**: Low-level WebSocket management
83
+ - **@casual-simulation/aux-common**: AUX common types and interfaces
84
+ - **rxjs**: Observable-based event handling
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ npm install @casual-simulation/aux-websocket
90
+ ```
package/package.json CHANGED
@@ -1,45 +1,44 @@
1
1
  {
2
- "name": "@casual-simulation/aux-websocket",
3
- "version": "3.8.2-alpha.19511653187",
4
- "description": "Websocket integration with AUX services",
5
- "keywords": [],
6
- "author": "Casual Simulation, Inc.",
7
- "homepage": "https://github.com/casual-simulation/casualos",
8
- "license": "AGPL-3.0-only",
9
- "main": "index.js",
10
- "types": "index.d.ts",
11
- "module": "index",
12
- "directories": {
13
- "lib": "."
14
- },
15
- "files": [
16
- "/README.md",
17
- "/LICENSE.txt",
18
- "**/*.js",
19
- "**/*.js.map",
20
- "**/*.d.ts"
21
- ],
22
- "repository": {
23
- "type": "git",
24
- "url": "git+https://github.com/casual-simulation/casualos.git"
25
- },
26
- "scripts": {
27
- "watch": "tsc --watch",
28
- "watch:player": "npm run watch",
29
- "build": "echo \"Nothing to do.\"",
30
- "test": "jest",
31
- "test:watch": "jest --watchAll"
32
- },
33
- "bugs": {
34
- "url": "https://github.com/casual-simulation/casualos/issues"
35
- },
36
- "publishConfig": {
37
- "access": "public"
38
- },
39
- "dependencies": {
40
- "@casual-simulation/aux-common": "^3.8.2-alpha.19511653187",
41
- "@casual-simulation/websocket": "^3.5.3",
42
- "rxjs": "8.0.0-alpha.14"
43
- },
44
- "gitHead": "8ba1ed060b9cc71e0af79550480958ce2e930ccb"
45
- }
2
+ "name": "@casual-simulation/aux-websocket",
3
+ "version": "3.10.2",
4
+ "description": "Websocket integration with AUX services",
5
+ "keywords": [],
6
+ "author": "Casual Simulation, Inc.",
7
+ "homepage": "https://github.com/casual-simulation/casualos",
8
+ "license": "AGPL-3.0-only",
9
+ "main": "index.js",
10
+ "types": "index.d.ts",
11
+ "module": "index",
12
+ "directories": {
13
+ "lib": "."
14
+ },
15
+ "files": [
16
+ "/README.md",
17
+ "/LICENSE.txt",
18
+ "**/*.js",
19
+ "**/*.js.map",
20
+ "**/*.d.ts"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/casual-simulation/casualos.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/casual-simulation/casualos/issues"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@casual-simulation/aux-common": "^3.10.2",
34
+ "@casual-simulation/websocket": "^3.10.2",
35
+ "rxjs": "8.0.0-alpha.14"
36
+ },
37
+ "scripts": {
38
+ "watch": "tsc --watch",
39
+ "watch:player": "npm run watch",
40
+ "build": "echo \"Nothing to do.\"",
41
+ "test": "jest",
42
+ "test:watch": "jest --watchAll"
43
+ }
44
+ }