我編寫了以下類來創建 JGroup 集群:public class TestClient extends ReceiverAdapter {JChannel channel;private void start() throws Exception { channel=new JChannel().setReceiver(this); channel.connect("ChatCluster"); eventLoop(); channel.close();}private void eventLoop() { while(true) { }}public void viewAccepted(View new_view) { System.out.println("** view: " + new_view); System.out.println("Get Coord"+new_view.getCoord()); System.out.println(new_view.getMembers());}public void receive(Message msg) { System.out.println(msg.getSrc() + ": " + msg.getObject());}public void getState(OutputStream output) throws Exception {}public void setState(InputStream input) throws Exception {}}ReceiverAdapter 是一個 Jgroups 定義的類:public class ReceiverAdapter implements Receiver {public ReceiverAdapter() {}public void receive(Message msg) {}public void receive(MessageBatch batch) { Iterator var2 = batch.iterator(); while(var2.hasNext()) { Message msg = (Message)var2.next(); try { this.receive(msg); } catch (Throwable var5) { ; } }}public void getState(OutputStream output) throws Exception {}public void setState(InputStream input) throws Exception {}public void viewAccepted(View view) {}public void suspect(Address mbr) {}public void block() {}public void unblock() {}}我的問題是如何在視圖更改或發送/接收消息時調用 ReceiverAdapter 類中的這些方法,因為我不需要顯式調用這些方法。JGroups 是否實現了某種事件偵聽器?
如果我沒有明確調用它們,那么如何在 jgroups 中調用 ReceiverAdapter
慕婉清6462132
2021-07-16 17:15:46