Search in sources :

Example 1 with RawInputHandler

use of com.swiftmq.net.protocol.raw.RawInputHandler in project swiftmq-ce by iitsoftware.

the class MQTTSwiftlet method createListener.

private void createListener(Entity listenerEntity) throws SwiftletException {
    Entity connectionTemplate = getConnectionTemplate((String) listenerEntity.getProperty("connection-template").getValue());
    String listenerName = listenerEntity.getName();
    int port = ((Integer) listenerEntity.getProperty("port").getValue()).intValue();
    InetAddress bindAddress = null;
    try {
        String s = (String) listenerEntity.getProperty("bindaddress").getValue();
        if (s != null && s.trim().length() > 0)
            bindAddress = InetAddress.getByName(s);
    } catch (Exception e) {
        throw new SwiftletException(e.getMessage());
    }
    int inputBufferSize = ((Integer) connectionTemplate.getProperty("router-input-buffer-size").getValue()).intValue();
    int inputExtendSize = ((Integer) connectionTemplate.getProperty("router-input-extend-size").getValue()).intValue();
    int outputBufferSize = ((Integer) connectionTemplate.getProperty("router-output-buffer-size").getValue()).intValue();
    int outputExtendSize = ((Integer) connectionTemplate.getProperty("router-output-extend-size").getValue()).intValue();
    boolean useTCPNoDelay = ((Boolean) connectionTemplate.getProperty("use-tcp-no-delay").getValue()).booleanValue();
    ListenerMetaData meta = new ListenerMetaData(bindAddress, port, this, -1, (String) connectionTemplate.getProperty("socketfactory-class").getValue(), new Acceptor(listenerName, listenerEntity.getProperty("max-connections"), listenerEntity.getProperty("connection-template")), inputBufferSize, inputExtendSize, outputBufferSize, outputExtendSize, useTCPNoDelay, new RawInputHandler(), new RawOutputHandler());
    listenerEntity.setUserObject(meta);
    createHostAccessList(meta, (EntityList) listenerEntity.getEntity("host-access-list"));
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(getName(), "starting listener '" + listenerName + "' ...");
    try {
        ctx.networkSwiftlet.createTCPListener(meta);
    } catch (Exception e) {
        throw new SwiftletException(e.getMessage());
    }
}
Also used : RawOutputHandler(com.swiftmq.net.protocol.raw.RawOutputHandler) SwiftletException(com.swiftmq.swiftlet.SwiftletException) ConnectionVetoException(com.swiftmq.swiftlet.net.ConnectionVetoException) RawInputHandler(com.swiftmq.net.protocol.raw.RawInputHandler) SwiftletException(com.swiftmq.swiftlet.SwiftletException) ListenerMetaData(com.swiftmq.swiftlet.net.ListenerMetaData) InetAddress(java.net.InetAddress)

Aggregations

RawInputHandler (com.swiftmq.net.protocol.raw.RawInputHandler)1 RawOutputHandler (com.swiftmq.net.protocol.raw.RawOutputHandler)1 SwiftletException (com.swiftmq.swiftlet.SwiftletException)1 ConnectionVetoException (com.swiftmq.swiftlet.net.ConnectionVetoException)1 ListenerMetaData (com.swiftmq.swiftlet.net.ListenerMetaData)1 InetAddress (java.net.InetAddress)1