Search in sources :

Example 1 with InvalidServicePasswordError

use of sugar.free.sightparser.error.InvalidServicePasswordError in project SightRemote by TebbeUbben.

the class RequestWorker method requestNext.

private void requestNext(Pipeline pipeline) {
    if (messageRequests.size() == 0)
        return;
    MessageRequest messageRequest = null;
    while (messageRequests.size() != 0) {
        messageRequest = messageRequests.get(0);
        if (!messageRequest.getBinder().isBinderAlive()) {
            messageRequests.remove(messageRequest);
            if (messageRequests.size() == 0)
                return;
            else
                continue;
        } else
            break;
    }
    Service service = messageRequest.getAppLayerMessage().getService();
    if (!pipeline.getActivatedServices().contains(service)) {
        messageRequest.setMessageStatus(MessageStatus.ACTIVATING_SERVICE);
        if (service.getServicePassword() != null) {
            if (service.getServicePassword().length() != 16)
                pipeline.receive(new InvalidServicePasswordError(messageRequest.getAppLayerMessage().getClass(), (short) 0x99F0));
            else {
                ServiceChallengeMessage serviceChallenge = new ServiceChallengeMessage();
                serviceChallenge.setServiceID(service.getServiceID());
                serviceChallenge.setVersion(service.getVersion());
                pipeline.send(serviceChallenge);
            }
        } else {
            ActivateServiceMessage activateService = new ActivateServiceMessage();
            activateService.setServiceID(service.getServiceID());
            activateService.setVersion(service.getVersion());
            activateService.setServicePassword(new byte[16]);
            pipeline.send(activateService);
        }
    } else {
        messageRequest.setMessageStatus(MessageStatus.PENDING);
        if (service.getServicePassword() != null && service.getServicePassword().length() != 16)
            pipeline.receive(new InvalidServicePasswordError(messageRequest.getAppLayerMessage().getClass(), (short) 0x99F0));
        else
            pipeline.send(messageRequest.getAppLayerMessage());
    }
}
Also used : InvalidServicePasswordError(sugar.free.sightparser.error.InvalidServicePasswordError) ActivateServiceMessage(sugar.free.sightparser.applayer.messages.connection.ActivateServiceMessage) MessageRequest(sugar.free.sightparser.handling.MessageRequest) ServiceChallengeMessage(sugar.free.sightparser.applayer.messages.connection.ServiceChallengeMessage) Service(sugar.free.sightparser.applayer.descriptors.Service)

Aggregations

Service (sugar.free.sightparser.applayer.descriptors.Service)1 ActivateServiceMessage (sugar.free.sightparser.applayer.messages.connection.ActivateServiceMessage)1 ServiceChallengeMessage (sugar.free.sightparser.applayer.messages.connection.ServiceChallengeMessage)1 InvalidServicePasswordError (sugar.free.sightparser.error.InvalidServicePasswordError)1 MessageRequest (sugar.free.sightparser.handling.MessageRequest)1