Search in sources :

Example 1 with MissingCommandException

use of de.mossgrabers.controller.osc.exception.MissingCommandException in project DrivenByMoss by git-moss.

the class OSCParser method handle.

/**
 * {@inheritDoc}
 */
@Override
public void handle(final IOpenSoundControlMessage message) {
    this.logMessage(message);
    final LinkedList<String> oscParts = parseAddress(message);
    if (oscParts.isEmpty())
        return;
    final String command = oscParts.removeFirst();
    if ("refresh".equals(command)) {
        this.writer.flush(true);
        return;
    }
    final Object[] values = message.getValues();
    try {
        final IModule module = this.modules.get(command);
        if (module == null)
            throw new UnknownCommandException(command);
        if (values != null && values.length > 1)
            module.execute(command, oscParts, values);
        else
            module.execute(command, oscParts, values == null || values.length == 0 ? null : values[0]);
    } catch (final IllegalParameterException ex) {
        this.host.println("Illegal parameter: " + message.getAddress() + " " + ex.getMessage());
    } catch (final UnknownCommandException ex) {
        this.host.println("Unknown OSC command: " + message.getAddress() + " " + ex.getMessage());
    } catch (final MissingCommandException ex) {
        this.host.println("Missing command: " + message.getAddress());
    }
}
Also used : IModule(de.mossgrabers.controller.osc.module.IModule) UnknownCommandException(de.mossgrabers.controller.osc.exception.UnknownCommandException) IllegalParameterException(de.mossgrabers.controller.osc.exception.IllegalParameterException) MissingCommandException(de.mossgrabers.controller.osc.exception.MissingCommandException)

Aggregations

IllegalParameterException (de.mossgrabers.controller.osc.exception.IllegalParameterException)1 MissingCommandException (de.mossgrabers.controller.osc.exception.MissingCommandException)1 UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)1 IModule (de.mossgrabers.controller.osc.module.IModule)1