case Event.DISCONNECT_OK:
disconnect_promise.setResult(Boolean.TRUE);
break;
case Event.GET_STATE_OK:
StateTransferInfo info=(StateTransferInfo)evt.getArg();
byte[] state=info.state;
state_promise.setResult(state != null? Boolean.TRUE : Boolean.FALSE);
if(up_handler != null) {
up_handler.up(evt);
return;
}
if(state != null) {
String state_id=info.state_id;
if(receiver != null) {
if(receiver instanceof ExtendedReceiver && state_id!=null)
((ExtendedReceiver)receiver).setState(state_id, state);
else
receiver.setState(state);
}
else {
try {mq.add(new Event(Event.STATE_RECEIVED, info));} catch(Exception e) {}
}
}
break;
case Event.STATE_TRANSFER_INPUTSTREAM:
StateTransferInfo sti=(StateTransferInfo)evt.getArg();
InputStream is=sti.inputStream;
//Oct 13,2006 moved to down() when Event.STATE_TRANSFER_INPUTSTREAM_CLOSED is received
//state_promise.setResult(is != null? Boolean.TRUE : Boolean.FALSE);
if(up_handler != null) {
up_handler.up(evt);
return;
}
if(is != null) {
if(receiver instanceof ExtendedReceiver) {
if(sti.state_id == null)
((ExtendedReceiver)receiver).setState(is);
else
((ExtendedReceiver)receiver).setState(sti.state_id, is);
}
else {
try {
mq.add(new Event(Event.STATE_TRANSFER_INPUTSTREAM, sti));
}
catch(Exception e) {
}
}
}
break;
case Event.SET_LOCAL_ADDRESS:
local_addr_promise.setResult(evt.getArg());
break;
case Event.EXIT:
handleExit(evt);
return; // no need to pass event up; already done in handleExit()
default:
break;
}
// If UpHandler is installed, pass all events to it and return (UpHandler is e.g. a building block)
if(up_handler != null) {
up_handler.up(evt);
if(type == Event.UNBLOCK){
flush_unblock_promise.setResult(Boolean.TRUE);
}
return;
}
switch(type) {
case Event.MSG:
if(receiver != null) {
receiver.receive((Message)evt.getArg());
return;
}
break;
case Event.VIEW_CHANGE:
if(receiver != null) {
receiver.viewAccepted((View)evt.getArg());
return;
}
break;
case Event.SUSPECT:
if(receiver != null) {
receiver.suspect((Address)evt.getArg());
return;
}
break;
case Event.GET_APPLSTATE:
if(receiver != null) {
StateTransferInfo info=(StateTransferInfo)evt.getArg();
byte[] tmp_state;
String state_id=info.state_id;
if(receiver instanceof ExtendedReceiver && state_id!=null) {
tmp_state=((ExtendedReceiver)receiver).getState(state_id);
}
else {
tmp_state=receiver.getState();
}
returnState(tmp_state, state_id);
return;
}
break;
case Event.STATE_TRANSFER_OUTPUTSTREAM:
if(receiver != null) {
StateTransferInfo sti=(StateTransferInfo)evt.getArg();
OutputStream os=sti.outputStream;
if(os != null && receiver instanceof ExtendedReceiver) {
if(sti.state_id == null)
((ExtendedReceiver)receiver).getState(os);
else