while (isConnected()) {
try {
final Message request = receiver.receive();
if (request != null) {
// inform sender that a message has arrived
sender.messageReceived();
// refresh transmission timeout
refreshTransmissionTimeout();
if (wasSentFromHere(request)) {
request.onResponse(this, context);
} else {
request.onRequest(this, context);
}
if (CloudService.DEBUG) {
System.out.println(" => " + request);
}