Listener<FriendMessageEvent> subscribe;
@Override
public void start() {
subscribe = GlobalEventChannel.INSTANCE.subscribe(FriendMessageEvent.class, event -> {
MessageChain message = event.getMessage();
message.forEach(m -> {
if (m instanceof MessageContent) {
String str = m.contentToString();
event.getSubject().sendMessage(str);
}
});
return ListeningStatus.LISTENING;
});
}
@Override
public void stop() {
System.out.println("结果==》" + subscribe.complete());
}
%(#55d929)[如果 handler 返回 ListeningStatus.STOPPED 监听器将被停止.
也可以通过 subscribe 返回值 Listener 的 Listener.complete]