try {
packetBytes = rmiServerRecv.receiveBytes(packetBytes);
if (packetBytes != null) {
- //System.out.println("Packet received: " + Arrays.toString(packetBytes));
int packetType = IoTRMIComm.getPacketType(packetBytes);
if (packetType == IoTRMIUtil.METHOD_TYPE) {
- //System.out.println("Method packet: " + Arrays.toString(packetBytes));
methodQueue.offer(packetBytes);
} else if (packetType == IoTRMIUtil.RET_VAL_TYPE) {
- //System.out.println("Return value packet: " + Arrays.toString(packetBytes));
returnQueue.offer(packetBytes);
} else
throw new Error("IoTRMICommServer: Packet type is unknown: " + packetType);
- } //else
- // Thread.sleep(100);
+ }
packetBytes = null;
} catch (Exception ex) {
ex.printStackTrace();
public synchronized void sendReturnObj(Object retObj, byte[] methodBytes) {
// Send back return value
- //byte[] retObjBytes = IoTRMIUtil.getObjectBytes(retObj);
byte[] retObjBytes = null;
if (retObj != null) // Handle nullness
retObjBytes = IoTRMIUtil.getObjectBytes(retObj);
// Send return value together with OBJECT_ID and METHOD_ID for arbitration
int objMethIdLen = IoTRMIUtil.OBJECT_ID_LEN + IoTRMIUtil.METHOD_ID_LEN;
int headerLen = objMethIdLen + IoTRMIUtil.PACKET_TYPE_LEN;
- //byte[] retAllBytes = new byte[headerLen + retObjBytes.length];
byte[] retAllBytes = null;
if (retObj == null) // Handle nullness
retAllBytes = new byte[headerLen];