-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_onError.java
36 lines (31 loc) · 1.09 KB
/
test_onError.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import io.github.kloping.qqbot.Starter;
import io.github.kloping.qqbot.api.Intents;
import io.github.kloping.qqbot.network.AuthAndHeartbeat;
import io.github.kloping.qqbot.network.WebSocketListener;
import io.github.kloping.spt.annotations.AutoStand;
import org.java_websocket.client.WebSocketClient;
/**
* 将 wss error 加入重连
* @author github.kloping
*/
public class test_onError implements WebSocketListener {
@AutoStand
AuthAndHeartbeat authAndHeartbeat;
@AutoStand
Starter starter;
@Override
public boolean onError(WebSocketClient client, Exception e) {
//尝试重连
authAndHeartbeat.identifyConnect(0, client);
return WebSocketListener.super.onError(client, e);
}
public static void main(String[] args) throws Exception {
Starter starter = new Starter("xxx", "xxx");
starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());
//设置websocket 监听
starter.getConfig().setWebSocketListener(new test_onError());
//切换沙盒
starter.getConfig().sandbox();
starter.run();
}
}