Add websocket support (#13)

Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
iGoX committed 2026-10-16 19:24:00 +02:00
1 parent ce0579b672
commit 26d200e282
16 files changed
+1042 -168

No files matched your search

+23 -13
View File
@@ -38,14 +38,15 @@ Supports **Android**, **macOS**, and **Windows**.
### Brightness
- Brightness slider (0–100%)
### Background polling
- Automatically pulls status + color from device at a configurable interval
### Live updates
- Subscribes to `/ws/status` for live status, color, and brightness updates
- Automatically reconnects after a disconnect or device address change
- Silent updates — no loading screen interruption
- Configurable in Settings (default: every second, can be disabled)
- Initial state comes from the WebSocket; no REST polling is used
- Keeps the last received state visible while reconnecting
### Settings
- Device address (hostname or IP, e.g. `http://igox-busylight.local`)
- Polling interval slider (Off → 1 min)
- Start with session (macOS and Windows only) — launch automatically at login
### UX & feedback
@@ -86,10 +87,10 @@ busylight_app/
│ │ ├── busylight_color.dart # Color model (r/g/b/brightness)
│ │ └── color_preset.dart # Named color preset model
│ ├── services/
│ │ ├── busylight_service.dart # All REST API calls
│ │ ├── busylight_service.dart # REST API calls and WebSocket status stream
│ │ └── autostart_service.dart # Start with session (macOS + Windows)
│ ├── providers/
│ │ ├── busylight_provider.dart # Status, color, brightness, polling, config
│ │ ├── busylight_provider.dart # Live status, color, brightness, config
│ │ └── presets_provider.dart # Custom color presets (CRUD + persistence)
│ ├── screens/
│ │ ├── home_screen.dart # Main screen
@@ -106,19 +107,28 @@ busylight_app/
| Endpoint | Method | Description |
|---|---|---|
| `/api/status` | GET | Get current status |
| `/api/status/available` | POST/GET | Set available (green) |
| `/api/status/away` | POST/GET | Set away (yellow) |
| `/api/status/busy` | POST/GET | Set busy (red) |
| `/api/status/on` | POST/GET | Turn on (white) |
| `/api/status/off` | POST/GET | Turn off |
| `/api/color` | GET | Get current color + brightness |
| `/ws/status` | WebSocket | Initial state and live status, color, brightness updates |
| `/api/status/available` | POST | Set available (green) |
| `/api/status/away` | POST | Set away (yellow) |
| `/api/status/busy` | POST | Set busy (red) |
| `/api/status/on` | POST | Turn on (white) |
| `/api/status/off` | POST | Turn off |
| `/api/color` | POST | Set custom color (r, g, b, brightness) |
---
## Platform setup
### macOS — build release
Requires macOS 12.0 or newer.
```bash
flutter build macos
```
The Flutter Xcode build phases use `macos/toolchain/lipo` to work around Xcode 27.1 rejecting Flutter's multi-architecture `-verify_arch` call. It verifies each requested architecture separately and delegates all other operations to the system tool. The app remains universal (Intel and Apple Silicon); no Flutter SDK modifications are needed.
### Android — build APK
Two helper scripts are available in the `android/` folder to build and rename the APK in one step — one for macOS/Linux, one for Windows.