我正在尝试实现一个处理程序方法,该方法可以根据传递到空间的参数进行通知。例如,我有以下代码将模板放入空间,其中 tab 是房间的名称:
private void createMessageListener(String tab) {
// create the exporter
Exporter myDefaultExporter =
new BasicJeriExporter (TcpServerEndpoint.getInstance(0),
new BasicILFactory(), false, true);
try {
// register this as a remote object
// and get a reference to the 'stub'
msgListener = (RemoteEventListener) myDefaultExporter.export(this);
// add the listener
Message template = new Message(tab);
regMsgs = space.notify(template, null, this.msgListener, Lease.FOREVER, null);
seqMsgs = regMsgs.getSequenceNumber();
} catch (Exception e) {
e.printStackTrace();
}
}
当尝试处理如下所示的事件注册时,有没有办法找出为通知方法传入的参数?
public void notify(RemoteEvent arg0) throws UnknownEventException,
RemoteException {
///Find out the parameter in the notification and then handle?
}
}