Phase transition planning and implementation notes
Last Updated: 2026-01-16 14:00 UTC
Status: Phase 2 COMPLETE β | Phase 3 Python SDK complete
All WebSocket functionality is production-ready:
| Component | Status |
| WebSocket Server | β Running on port 8090 |
| External WSS Access | β
wss://perti.vatcscc.org/api/swim/v1/ws |
| Event Detection | β Departures, arrivals, positions, TMIs |
| Database Auth | β
Validates against swim_api_keys |
| Tier Rate Limits | β Connection limits enforced |
| Python SDK | β Ready for use |
Completed:
1. Tier-based connection limits in WebSocketServer.php
- Tracks connectionsByTier counts
- Enforces limits on connect, decrements on disconnect
- Rejects with CONNECTION_LIMIT error when at max
- Shows tier in connect/disconnect logs
2. Tier limits:
| Tier | Max Connections |
|------|-----------------|
| public | 5 |
| developer | 50 |
| partner | 500 |
| system | 10,000 |
3. Documentation updated - All SWIM docs reflect completion
Completed:
1. Database authentication in WebSocketServer.php
- Validates API keys against dbo.swim_api_keys
- 5-minute key cache to reduce DB queries
- Checks is_active and expires_at
- Updates last_used_at on success
2. Python SDK - sdk/python/swim_client/
- Async WebSocket client with auto-reconnect
- Typed event data classes
- 4 example scripts
3. Poll interval reduced from 500ms to 100ms
Completed:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β ADL Daemon βββββββΆβ Event File βββββββΆβ WebSocket Hub β
β (15s refresh) β emit β (IPC queue) β poll β (Ratchet PHP) β
βββββββββββββββββββ βββββββββββββββββββ ββββββββββ¬βββββββββ
100ms polling β
β
ββββββββββββββββββ¬ββββββββββββββββ¬ββββββββββββ€
βΌ βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββ ββββββββββ
β CRC β β vNAS β βSimAwareβ β Custom β
ββββββββββ ββββββββββ ββββββββββ ββββββββββ
| Task | Est. Hours | Status |
| Python SDK | 12h | β DONE |
| Redis IPC | 4-6h | βΈοΈ Deferred |
| C# SDK | 12h | β³ As needed |
| Java SDK | 12h | β³ As needed |
| Message compression | 2h | β³ Low priority |
| Historical replay | 8h | β³ Low priority |
| Metrics dashboard | 4h | β³ Low priority |
Redis ($16/mo) deferred indefinitely. Current file-based IPC:
| File | Purpose |
scripts/swim_ws_server.php | WebSocket daemon |
scripts/swim_ws_events.php | Event detection queries |
api/swim/v1/ws/WebSocketServer.php | Server class (auth + rate limits) |
api/swim/v1/ws/ClientConnection.php | Client wrapper |
api/swim/v1/ws/SubscriptionManager.php | Subscription management |
api/swim/v1/ws/swim-ws-client.js | JavaScript client |
| File | Purpose |
sdk/python/swim_client/__init__.py | Package exports |
sdk/python/swim_client/client.py | SWIMClient class |
sdk/python/swim_client/events.py | Event data classes |
sdk/python/examples/basic_example.py | Simple usage |
sdk/python/examples/airport_monitor.py | Airport tracking |
sdk/python/examples/position_tracker.py | Position tracking |
sdk/python/examples/tmi_monitor.py | TMI monitoring |
CREATE TABLE dbo.swim_api_keys (
id INT IDENTITY(1,1) PRIMARY KEY,
api_key NVARCHAR(64) NOT NULL UNIQUE,
tier NVARCHAR(20) NOT NULL DEFAULT 'public',
owner_name NVARCHAR(100) NOT NULL,
owner_email NVARCHAR(255),
description NVARCHAR(500),
expires_at DATETIME2,
created_at DATETIME2 NOT NULL DEFAULT GETUTCDATE(),
last_used_at DATETIME2,
is_active BIT NOT NULL DEFAULT 1
);
| Key | Tier | Owner |
swim_dev_hp_test | developer | HP |
INSERT INTO dbo.swim_api_keys (api_key, tier, owner_name, owner_email, description)
VALUES (
'swim_' + LOWER(CONVERT(VARCHAR(36), NEWID())),
'developer',
'Name',
'email@example.com',
'Description'
);
pkill -f swim_ws_server
rm -f /home/site/wwwroot/scripts/swim_ws.lock
nohup php /home/site/wwwroot/scripts/swim_ws_server.php --debug > /home/LogFiles/swim_ws.log 2>&1 &
tail -f /home/LogFiles/swim_ws.log
cd sdk/python
pip install -e .
python examples/basic_example.py swim_dev_hp_test
| Event | Description |
flight.created | New pilot connected |
flight.departed | Wheels up (OFF time) |
flight.arrived | Wheels down (IN time) |
flight.deleted | Pilot disconnected |
flight.positions | Batched position updates |
tmi.issued | New GS/GDP issued |
tmi.released | TMI ended |
system.heartbeat | Server keepalive (30s) |
| Metric | Target | Achieved |
| External WSS | Working | β |
| DB Auth | Implemented | β |
| Tier Limits | Enforced | β |
| Python SDK | Complete | β |
| Event latency | < 15 sec | ~15 sec |
| Phase 2 | 100% | β |
1. Deploy rate limits - Files need to sync, then restart WS server
2. C#/Java SDKs - Build when consumers request
3. Metrics dashboard - Track usage patterns
4. Redis - Deploy when caching layer needed
| Component | Monthly |
| SWIM_API (Azure SQL Basic) | $5 |
| WebSocket (self-hosted) | $0 |
| Redis (deferred) | $0 |
| Total | $5 |