use of sugar.free.sightparser.error.DisconnectedError in project SightRemote by TebbeUbben.
the class RequestWorker method onInboundMessage.
@Override
public void onInboundMessage(final Object message, Pipeline pipeline) throws Exception {
synchronized (messageRequests) {
if (messageRequests.size() == 0)
return;
if (message instanceof DisconnectedError) {
for (MessageRequest messageRequest : new ArrayList<>(messageRequests)) {
sendError(messageRequest, (Exception) message);
messageRequests.remove(messageRequest);
}
return;
}
MessageRequest messageRequest = messageRequests.get(0);
if (message instanceof Exception) {
sendError(messageRequest, (Exception) message);
messageRequests.remove(messageRequest);
requestNext(pipeline);
return;
}
if (messageRequest.getMessageStatus() == MessageStatus.ACTIVATING_SERVICE) {
Service service = messageRequest.getAppLayerMessage().getService();
if (message instanceof ServiceChallengeMessage) {
byte[] password = Cryptograph.getServicePasswordHash(service.getServicePassword(), ((ServiceChallengeMessage) message).getRandomData());
ActivateServiceMessage activateService = new ActivateServiceMessage();
activateService.setServicePassword(password);
activateService.setServiceID(service.getServiceID());
activateService.setVersion(service.getVersion());
pipeline.send(activateService);
} else if (message instanceof ActivateServiceMessage) {
pipeline.getActivatedServices().add(service);
requestNext(pipeline);
}
} else if (messageRequest.getMessageStatus() == MessageStatus.PENDING && message instanceof AppLayerMessage) {
sendMessage(messageRequest, (AppLayerMessage) message);
messageRequests.remove(messageRequest);
requestNext(pipeline);
}
}
}
Aggregations