Search in sources :

Example 1 with SubscribeOptions

use of io.crossbar.autobahn.wamp.types.SubscribeOptions in project autobahn-java by crossbario.

the class Subscribe method parse.

public static Subscribe parse(List<Object> wmsg) {
    MessageUtil.validateMessage(wmsg, MESSAGE_TYPE, "SUBSCRIBE", 4);
    long request = MessageUtil.parseLong(wmsg.get(1));
    Map<String, Object> options = (Map<String, Object>) wmsg.get(2);
    String match = null;
    if (options.containsKey("match")) {
        match = (String) options.get("match");
        if (!match.equals(MATCH_EXACT) && !match.equals(MATCH_PREFIX) && !match.equals(MATCH_EXACT)) {
            throw new ProtocolError("match must be one of exact, prefix or wildcard.");
        }
    }
    boolean getRetained = getOrDefault(options, "get_retained", false);
    String topic = (String) wmsg.get(3);
    SubscribeOptions opt = new SubscribeOptions(match, true, getRetained);
    return new Subscribe(request, opt, topic);
}
Also used : SubscribeOptions(io.crossbar.autobahn.wamp.types.SubscribeOptions) Map(java.util.Map) HashMap(java.util.HashMap) ProtocolError(io.crossbar.autobahn.wamp.exceptions.ProtocolError)

Aggregations

ProtocolError (io.crossbar.autobahn.wamp.exceptions.ProtocolError)1 SubscribeOptions (io.crossbar.autobahn.wamp.types.SubscribeOptions)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1