|
| 1 | +# FCS WebSocket Library Sync Status |
| 2 | + |
| 3 | +**Last Synced:** 2025-12-24 |
| 4 | +**JS Version:** fcs-client-lib.js |
| 5 | +**PY Version:** fcs_client_lib.py |
| 6 | +**Status:** IN_SYNC |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Feature Comparison |
| 11 | + |
| 12 | +| Feature | JS | Python | Notes | |
| 13 | +|---------|:--:|:------:|-------| |
| 14 | +| **Core Connection** | |
| 15 | +| connect() | ✅ | ✅ | | |
| 16 | +| disconnect() | ✅ | ✅ | | |
| 17 | +| send() | ✅ | ✅ | `_send()` in Python | |
| 18 | +| **Subscription** | |
| 19 | +| join(symbol, timeframe) | ✅ | ✅ | | |
| 20 | +| leave(symbol, timeframe) | ✅ | ✅ | | |
| 21 | +| removeAll() | ✅ | ✅ | `remove_all()` in Python | |
| 22 | +| rejoinAll() | ✅ | ✅ | `_rejoin_all()` in Python | |
| 23 | +| activeSubscriptions | ✅ | ✅ | `active_subscriptions` in Python | |
| 24 | +| **Event Callbacks** | |
| 25 | +| onconnected | ✅ | ✅ | | |
| 26 | +| onmessage | ✅ | ✅ | | |
| 27 | +| onclose | ✅ | ✅ | | |
| 28 | +| onerror | ✅ | ✅ | | |
| 29 | +| onreconnect | ✅ | ✅ | | |
| 30 | +| **Reconnection** | |
| 31 | +| reconnectDelay | ✅ | ✅ | `reconnect_delay` in Python | |
| 32 | +| reconnectLimit | ✅ | ✅ | `reconnect_limit` in Python | |
| 33 | +| countReconnects | ✅ | ✅ | `count_reconnects` in Python | |
| 34 | +| isReconnect | ✅ | ✅ | `is_reconnect` in Python | |
| 35 | +| Auto-reconnect logic | ✅ | ✅ | | |
| 36 | +| **Heartbeat** | |
| 37 | +| startHeartbeat() | ✅ | ✅ | `_start_heartbeat()` in Python | |
| 38 | +| stopHeartbeat() | ✅ | ✅ | `_stop_heartbeat` flag in Python | |
| 39 | +| 25s interval | ✅ | ✅ | | |
| 40 | +| **Logging** | |
| 41 | +| showLogs | ✅ | ✅ | Controls console output | |
| 42 | +| **Message Handling** | |
| 43 | +| ping/pong | ✅ | ✅ | | |
| 44 | +| welcome message | ✅ | ✅ | | |
| 45 | +| joined_room confirmation | ✅ | ✅ | | |
| 46 | +| **Browser-Only (Not in Python)** | |
| 47 | +| focusTimeout | ✅ | ❌ | Browser tab visibility - N/A for Python | |
| 48 | +| initVisibilityHandling() | ✅ | ❌ | Browser only | |
| 49 | +| handleTabHidden() | ✅ | ❌ | Browser only | |
| 50 | +| handleTabVisible() | ✅ | ❌ | Browser only | |
| 51 | +| clearVisibilityTimeout() | ✅ | ❌ | Browser only | |
| 52 | +| **Python-Only Extras** | |
| 53 | +| run_forever(blocking) | ❌ | ✅ | Python threading support | |
| 54 | +| Decorator callbacks | ❌ | ✅ | @client.on_message pattern | |
| 55 | +| create_client() helper | ❌ | ✅ | Factory function | |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Properties Mapping |
| 60 | + |
| 61 | +| JavaScript | Python | |
| 62 | +|------------|--------| |
| 63 | +| `this.url` | `self.url` | |
| 64 | +| `this.apiKey` | `self.api_key` | |
| 65 | +| `this.socket` | `self.socket` | |
| 66 | +| `this.activeSubscriptions` | `self.active_subscriptions` | |
| 67 | +| `this.heartbeat` | `self._heartbeat_thread` | |
| 68 | +| `this.reconnectDelay` | `self.reconnect_delay` | |
| 69 | +| `this.manualClose` | `self.manual_close` | |
| 70 | +| `this.isConnected` | `self.is_connected` | |
| 71 | +| `this.showLogs` | `self.show_logs` | |
| 72 | +| `this.countreconnects` | `self.count_reconnects` | |
| 73 | +| `this.reconnectlimit` | `self.reconnect_limit` | |
| 74 | +| `this.isreconnect` | `self.is_reconnect` | |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## Sync Instructions |
| 79 | + |
| 80 | +When updating JS file, update Python file with these rules: |
| 81 | + |
| 82 | +1. **New property added in JS** → Add to Python `__init__` with snake_case |
| 83 | +2. **New method added in JS** → Add to Python class with snake_case |
| 84 | +3. **Property removed in JS** → Remove from Python |
| 85 | +4. **Method removed in JS** → Remove from Python |
| 86 | +5. **Logic changed in JS** → Update corresponding Python logic |
| 87 | + |
| 88 | +**Ignore these JS features (browser-only):** |
| 89 | +- Tab visibility handling (`focusTimeout`, `initVisibilityHandling`, etc.) |
| 90 | +- `WebSocketImpl` browser detection (Python always uses websocket-client) |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## Change Log |
| 95 | + |
| 96 | +### 2025-12-24 - Initial Sync |
| 97 | +- Added `show_logs` property to Python `__init__` |
| 98 | +- Updated all print statements to respect `show_logs` flag |
| 99 | +- All core features synced |
| 100 | +- Browser-only features excluded (not applicable to Python backend) |
| 101 | + |
0 commit comments