Skip to content

Commit 644e6d1

Browse files
committed
fix: websocket
1 parent e44d68b commit 644e6d1

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

docs/api/socket/index.mdx

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,77 @@ lb-\*.exptech.dev 為指定 Balance Server,若不加編號則由 DNS 自動分
2828

2929
:::
3030

31-
## 驗證
31+
## 連接
32+
33+
```json
34+
{
35+
"type": "start", // 類型
36+
"token": "<token>", // 驗證 Token (Service)
37+
"topic": ["<topic>"] // 欲訂閱主題
38+
}
39+
```
40+
41+
## 回應
42+
43+
### 連接成功
44+
45+
```json
46+
{
47+
"type": "info", // 類型
48+
"event": "connect", // 事件
49+
"topic": {
50+
"success": ["websocket.trem.rts.v1"], // 訂閱成功主題
51+
"failed": [] // 訂閱失敗主題
52+
},
53+
"time": 1724935200000 // 時間 (Unix Timestamp)
54+
}
55+
```
56+
57+
### 連接失敗
58+
59+
#### Reason 類型
60+
61+
- `Token has been revoked` Token 已被註銷 (在 Web 控制面板)
62+
- `Invalid message format` 訊息格式錯誤
63+
- `Token required` 未提供 Token (Service)
64+
- `Token invalid` Token (Service) 無效
65+
- `Monthly calls quota exceeded (xxx/xxx)` 月呼叫次數超過限制 (xxx 根據實際情況)
66+
- `Monthly bytes quota exceeded (xxx/xxx)` 月流量超過限制 (xxx 根據實際情況)
67+
- `Server error` 伺服器錯誤
68+
69+
```json
70+
{
71+
"type": "info", // 類型
72+
"event": "disconnect", // 事件
73+
"msg": "<reason>", // 訊息
74+
"time": 1724935200000 // 時間 (Unix Timestamp)
75+
}
76+
```
77+
78+
### NTP
79+
80+
```json
81+
{
82+
"type": "ntp", // 類型
83+
"time": 1724935200000 // 時間 (Unix Timestamp)
84+
}
85+
```
86+
87+
### 資料
88+
89+
```json
90+
{
91+
"type": "data", // 類型
92+
"topic": "websocket.trem.rts.v1", // 主題
93+
"payload": "<payload>", // 資料
94+
"time": 1724935200000 // 時間 (Unix Timestamp)
95+
}
96+
```
3297

3398
## 訂閱
99+
100+
下方列出可供訂閱的主題。
101+
102+
### RTS
103+
104+
- `websocket.trem.rts.v1`

0 commit comments

Comments
 (0)