mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-02-19 20:50:28 +08:00
将 LiveClient 中的 ConnectionClose 监听器变为内部类以防止外部直接调用
This commit is contained in:
parent
7f2947ad8a
commit
803290932d
@ -39,6 +39,10 @@ public class LiveClient implements Closeable {
|
||||
private EventLoopGroup eventLoopGroup;
|
||||
private Channel channel;
|
||||
|
||||
private void initEventBus() {
|
||||
eventBus.register(new ConnectionCloseListener());
|
||||
}
|
||||
|
||||
public LiveClient(BilibiliServiceProvider bilibiliServiceProvider, long showRoomId) {
|
||||
this.bilibiliServiceProvider = bilibiliServiceProvider;
|
||||
this.showRoomId = showRoomId;
|
||||
@ -53,10 +57,6 @@ public class LiveClient implements Closeable {
|
||||
initEventBus();
|
||||
}
|
||||
|
||||
private void initEventBus() {
|
||||
eventBus.register(this);
|
||||
}
|
||||
|
||||
public synchronized LiveClient connect() throws IOException {
|
||||
if (channel != null && channel.isActive()) {
|
||||
LOGGER.warn("Already connected to server, connect method can not be invoked twice");
|
||||
@ -130,9 +130,11 @@ public class LiveClient implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConnectionClose(ConnectionCloseEvent connectionCloseEvent) {
|
||||
eventLoopGroup.shutdownGracefully();
|
||||
private class ConnectionCloseListener {
|
||||
@Subscribe
|
||||
public void onConnectionClose(ConnectionCloseEvent connectionCloseEvent) {
|
||||
eventLoopGroup.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
|
||||
public EventBus getEventBus() {
|
||||
|
Loading…
Reference in New Issue
Block a user