当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中org.dna.mqtt.commons.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于org.dna.mqtt.commons包,在下文中一共展示了Constants类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializePlainTCPTransport

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
private void initializePlainTCPTransport(IMessaging messaging, Properties props) throws IOException {
    final NettyMQTTHandler handler = new NettyMQTTHandler();
    handler.setMessaging(messaging);
    String host = props.getProperty(Constants.HOST_PROPERTY_NAME);
    int port = Integer.parseInt(props.getProperty(Constants.PORT_PROPERTY_NAME));
    initFactory(host, port, new PipelineInitializer() {
        @Override
        void init(ChannelPipeline pipeline) {
            pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
            pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
            //pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
            pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
            pipeline.addLast("decoder", new MQTTDecoder());
            pipeline.addLast("encoder", new MQTTEncoder());
            pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
            pipeline.addLast("handler", handler);
        }
    });
}
 
开发者ID:wso2,项目名称:andes,代码行数:20,代码来源:NettyAcceptor.java

示例2: init

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
protected void init() {
        DemuxingProtocolDecoder decoder = new DemuxingProtocolDecoder();
        decoder.addMessageDecoder(new ConnAckDecoder());
        decoder.addMessageDecoder(new SubAckDecoder());
        decoder.addMessageDecoder(new UnsubAckDecoder());
        decoder.addMessageDecoder(new PublishDecoder());
        decoder.addMessageDecoder(new PubAckDecoder());
        decoder.addMessageDecoder(new PingRespDecoder());

        DemuxingProtocolEncoder encoder = new DemuxingProtocolEncoder();
        encoder.addMessageEncoder(ConnectMessage.class, new ConnectEncoder());
        encoder.addMessageEncoder(PublishMessage.class, new PublishEncoder());
        encoder.addMessageEncoder(SubscribeMessage.class, new SubscribeEncoder());
        encoder.addMessageEncoder(UnsubscribeMessage.class, new UnsubscribeEncoder());
        encoder.addMessageEncoder(DisconnectMessage.class, new DisconnectEncoder());
        encoder.addMessageEncoder(PingReqMessage.class, new PingReqEncoder());

        m_connector = new NioSocketConnector();

//        m_connector.getFilterChain().addLast("logger", new LoggingFilter());
        m_connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(encoder, decoder));

        m_connector.setHandler(new DummyClientHandler());
        m_connector.getSessionConfig().setReadBufferSize(2048);
        m_connector.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, Constants.DEFAULT_CONNECT_TIMEOUT);
    }
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:27,代码来源:MQTTBulkClient.java

示例3: initializeWebSocketTransport

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
private void initializeWebSocketTransport(IMessaging messaging, Properties props) throws IOException {
    String webSocketPortProp = props.getProperty(Constants.WEB_SOCKET_PORT_PROPERTY_NAME);
    if (webSocketPortProp == null) {
        //Do nothing no WebSocket configured
        log.info("WebSocket is disabled");
        return;
    }
    int port = Integer.parseInt(webSocketPortProp);

    final NettyMQTTHandler handler = new NettyMQTTHandler();
    handler.setMessaging(messaging);

    String host = props.getProperty(Constants.HOST_PROPERTY_NAME);
    initFactory(host, port, new PipelineInitializer() {
        @Override
        void init(ChannelPipeline pipeline) {
            pipeline.addLast("httpEncoder", new HttpResponseEncoder());
            pipeline.addLast("httpDecoder", new HttpRequestDecoder());
            pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
            pipeline.addLast("webSocketHandler", new WebSocketServerProtocolHandler("/mqtt"/*"/mqtt"*/, "mqttv3.1, mqttv3.1.1"));
            //pipeline.addLast("webSocketHandler", new WebSocketServerProtocolHandler(null, "mqtt"));
            pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder());
            pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder());
            pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
            pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
            pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
            pipeline.addLast("decoder", new MQTTDecoder());
            pipeline.addLast("encoder", new MQTTEncoder());
            pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
            pipeline.addLast("handler", handler);
        }
    });
}
 
开发者ID:wso2,项目名称:andes,代码行数:34,代码来源:NettyAcceptor.java

示例4: initializeSSLTCPTransport

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
/**
 * Initialize ssl tcp transport for mqtt
 * @param messaging
 * @param props
 * @param sslHandlerFactory
 * @throws IOException
 */
private void initializeSSLTCPTransport(IMessaging messaging, Properties props, final SSLHandlerFactory sslHandlerFactory)
        throws IOException {
    String sslPortProp = props.getProperty(Constants.SSL_PORT_PROPERTY_NAME);
    //TODO need to re visit
    sslPortProp = props.get(Constants.SSL_PORT_PROPERTY_NAME).toString();
    if (sslPortProp == null) {
        //Do nothing no SSL configured
        log.info("SSL is disabled");
        return;
    }

    int sslPort = Integer.parseInt(sslPortProp);
    log.info("Starting SSL on port {}", sslPort);

    final NettyMQTTHandler handler = new NettyMQTTHandler();
    handler.setMessaging(messaging);
    String host = props.getProperty(Constants.HOST_PROPERTY_NAME);
    initFactory(host, sslPort, new PipelineInitializer() {
        @Override
        void init(ChannelPipeline pipeline) throws Exception {
            pipeline.addLast("ssl", sslHandlerFactory.create());
            pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
            pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
            //pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
            pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
            pipeline.addLast("decoder", new MQTTDecoder());
            pipeline.addLast("encoder", new MQTTEncoder());
            pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
            pipeline.addLast("handler", handler);
        }
    });
}
 
开发者ID:wso2,项目名称:andes,代码行数:40,代码来源:NettyAcceptor.java

示例5: initializeWSSTransport

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
private void initializeWSSTransport(IMessaging messaging, Properties props, final SslHandler sslHandler)
        throws IOException {
    String sslPortProp = props.getProperty(Constants.WSS_PORT_PROPERTY_NAME);
    if (sslPortProp == null) {
        //Do nothing no SSL configured
        log.info("SSL is disabled");
        return;
    }
    int sslPort = Integer.parseInt(sslPortProp);
    final NettyMQTTHandler handler = new NettyMQTTHandler();
    handler.setMessaging(messaging);
    String host = props.getProperty(Constants.HOST_PROPERTY_NAME);
    initFactory(host, sslPort, new PipelineInitializer() {
        @Override
        void init(ChannelPipeline pipeline) throws Exception {
            pipeline.addLast("ssl", sslHandler);
            pipeline.addLast("httpEncoder", new HttpResponseEncoder());
            pipeline.addLast("httpDecoder", new HttpRequestDecoder());
            pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
            pipeline.addLast("webSocketHandler", new WebSocketServerProtocolHandler("/mqtt", "mqttv3.1, mqttv3.1.1"));
            pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder());
            pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder());
            pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
            pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
            pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
            pipeline.addLast("decoder", new MQTTDecoder());
            pipeline.addLast("encoder", new MQTTEncoder());
            pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
            pipeline.addLast("handler", handler);
        }
    });
}
 
开发者ID:wso2,项目名称:andes,代码行数:33,代码来源:NettyAcceptor.java

示例6: initializePlainTCPTransport

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
private void initializePlainTCPTransport(IMessaging messaging, Properties props) throws IOException {
//        m_bossGroup = new NioEventLoopGroup();
//        m_workerGroup = new NioEventLoopGroup();

        final NettyMQTTHandler handler = new NettyMQTTHandler();
        handler.setMessaging(messaging);

        ServerBootstrap b = new ServerBootstrap();
        b.group(m_bossGroup, m_workerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ChannelPipeline pipeline = ch.pipeline();
                    //pipeline.addFirst("metrics", new BytesMetricsHandler(m_metricsCollector));
                        pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
                        pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
                        //pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
                        pipeline.addLast("decoder", new MQTTDecoder());
                        pipeline.addLast("encoder", new MQTTEncoder());
                        pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
                        pipeline.addLast("handler", handler);
                    }
                })
                .option(ChannelOption.SO_BACKLOG, 128)
                .option(ChannelOption.SO_REUSEADDR, true)
                .childOption(ChannelOption.SO_KEEPALIVE, true);
        try {
            // Bind and start to accept incoming connections.
//            ChannelFuture f = b.bind(Constants.PORT);
            ChannelFuture f = b.bind(props.getProperty("host"), Integer.parseInt(props.getProperty("port")));
            Log.info("Server binded");
            f.sync();
        } catch (InterruptedException ex) {
            Log.error(null, ex);
        }
    }
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:38,代码来源:NettyAcceptor.java

示例7: initialize

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
public void initialize(IMessaging messaging) throws IOException {
    m_bossGroup = new NioEventLoopGroup();
    m_workerGroup = new NioEventLoopGroup();
    
    final NettyMQTTHandler handler = new NettyMQTTHandler();
    handler.setMessaging(messaging);

    ServerBootstrap b = new ServerBootstrap();
        b.group(m_bossGroup, m_workerGroup)
         .channel(NioServerSocketChannel.class) 
         .childHandler(new ChannelInitializer<SocketChannel>() { 
             @Override
             public void initChannel(SocketChannel ch) throws Exception {
                ChannelPipeline pipeline = ch.pipeline();
                //pipeline.addFirst("metrics", new BytesMetricsHandler(m_metricsCollector));
                pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
                pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
                //pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
                pipeline.addLast("decoder", new MQTTDecoder());
                pipeline.addLast("encoder", new MQTTEncoder());
                pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
                pipeline.addLast("handler", handler);
             }
         })
         .option(ChannelOption.SO_BACKLOG, 128)
         .option(ChannelOption.SO_REUSEADDR, true)
         .childOption(ChannelOption.SO_KEEPALIVE, true); 
    try {    
        // Bind and start to accept incoming connections.
        ChannelFuture f = b.bind(Constants.PORT);
        LOG.info("Server binded");
        f.sync();
    } catch (InterruptedException ex) {
        LOG.error(null, ex);
    }
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:37,代码来源:NettyAcceptor.java

示例8: loadConfigurations

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
/**
 * Load configurations related to MQTT from Andes configuration files.
 *
 * @return Property collection
 * @throws AndesException
 */
private Properties loadConfigurations() {

    Properties mqttProperties = new Properties();

    mqttProperties.put(Constants.SSL_PORT_PROPERTY_NAME,AndesConfigurationManager.
                                      readValue(AndesConfiguration.TRANSPORTS_MQTT_DEFAULT_CONNECTION_PORT));

    mqttProperties.put(Constants.SSL_PORT_PROPERTY_NAME,AndesConfigurationManager.
                                      readValue(AndesConfiguration.TRANSPORTS_MQTT_SSL_CONNECTION_PORT));

    mqttProperties.put(Constants.SSL_CONNECTION_ENABLED,AndesConfigurationManager.
                                      readValue(AndesConfiguration.TRANSPORTS_MQTT_SSL_CONNECTION_ENABLED));

    mqttProperties.put(Constants.DEFAULT_CONNECTION_ENABLED,AndesConfigurationManager.
                                      readValue(AndesConfiguration.TRANSPORTS_MQTT_DEFAULT_CONNECTION_ENABLED));

    mqttProperties.put(Constants.HOST_PROPERTY_NAME,AndesConfigurationManager.
                                      readValue(AndesConfiguration.TRANSPORTS_MQTT_BIND_ADDRESS));
    
    return mqttProperties;
}
 
开发者ID:wso2,项目名称:andes,代码行数:28,代码来源:Server.java

示例9: initialize

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
@Override
public void initialize(IMessaging messaging, Properties props) throws IOException {
    m_bossGroup = new NioEventLoopGroup();
    m_workerGroup = new NioEventLoopGroup();

    /**
     * We leave the websockets commented for now since we do not support end to end integration with it
     */
    //initializeWebSocketTransport(messaging, props);
    //TODO need to re look into using getProperty here
    String sslTcpPortProp = props.get(Constants.SSL_PORT_PROPERTY_NAME).toString();
    String wssPortProp = props.getProperty(Constants.WSS_PORT_PROPERTY_NAME);
    Boolean sslPortEnabled = Boolean.parseBoolean(props.get(Constants.SSL_CONNECTION_ENABLED).toString());
    Boolean defaultPortEnabled = Boolean.parseBoolean(props.get(Constants.DEFAULT_CONNECTION_ENABLED).toString());

    // non-secure port will be enabled/disabled as per configuration.
    if(defaultPortEnabled) {
        initializePlainTCPTransport(messaging, props);
    } else {
        log.warn("MQTT port has disabled as per configuration.");
    }


    /* if (sslTcpPortProp != null || wssPortProp != null) {
        SslHandler sslHandler = initSSLHandler(props);
        if (sslHandler == null) {
            log.error("Can't initialize SSLHandler layer! Exiting, check your configuration of jks");
            return;
        }
        initializeSSLTCPTransport(messaging, props, sslHandler);
        initializeWSSTransport(messaging, props, sslHandler);
    }*/

    if (sslTcpPortProp != null && sslPortEnabled) {
        SSLHandlerFactory sslHandlerFactory = initSSLHandlerFactory(props);
        if (!sslHandlerFactory.canCreate()) {
            log.error("Can't initialize SSLHandler layer! Exiting, check your configuration of jks");
            return;
        }
        initializeSSLTCPTransport(messaging, props, sslHandlerFactory);
        /**
         * We ommit web sockets for now
         */
        //initializeWSSTransport(messaging, props, sslHandler);
    } else {
        log.warn("MQTT SSL port not readable or has been disabled as per configuration.");
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:49,代码来源:NettyAcceptor.java

示例10: ConfigurationParser

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
ConfigurationParser() {
    m_properties.put("port", Integer.toString(Constants.PORT));
    m_properties.put("host", Constants.HOST);
}
 
开发者ID:wso2,项目名称:andes,代码行数:5,代码来源:ConfigurationParser.java

示例11: initializeSSLTCPTransport

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
private void initializeSSLTCPTransport(IMessaging messaging, Properties props) throws IOException {
        String sslPortProp = props.getProperty("ssl_port");
        if (sslPortProp == null) {
            //Do nothing no SSL configured
            Log.info("SSL is disabled");
            return;
        }
        final String jksPath = props.getProperty("jks_path");
        if (jksPath == null || jksPath.isEmpty()) {
            //key_store_password or key_manager_password are empty
            Log.warn("You have configured the SSL port but not the jks_path, SSL not started");
            return;
        }
        
        //if we have the port also the jks then keyStorePassword and keyManagerPassword 
        //has to be defined
        final String keyStorePassword = props.getProperty("key_store_password");
        final String keyManagerPassword = props.getProperty("key_manager_password");
        if (keyStorePassword == null || keyStorePassword.isEmpty()) {
            //key_store_password or key_manager_password are empty
            Log.warn("You have configured the SSL port but not the key_store_password, SSL not started");
            return;
        }
        if (keyManagerPassword == null || keyManagerPassword.isEmpty()) {
            //key_manager_password or key_manager_password are empty
            Log.warn("You have configured the SSL port but not the key_manager_password, SSL not started");
            return;
        }
        
        int sslPort = Integer.parseInt(sslPortProp);
        
        final NettyMQTTHandler handler = new NettyMQTTHandler();
        handler.setMessaging(messaging);

        ServerBootstrap b = new ServerBootstrap();
        b.group(m_bossGroup, m_workerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        InputStream jksInputStream = getClass().getClassLoader().getResourceAsStream(jksPath);
                        SSLContext serverContext = SSLContext.getInstance("TLS");
                        final KeyStore ks = KeyStore.getInstance("JKS");
                        ks.load(jksInputStream, keyStorePassword.toCharArray());
                        final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
                        kmf.init(ks, keyManagerPassword.toCharArray());
                        serverContext.init(kmf.getKeyManagers(), null, null);
                        
                        SSLEngine engine = serverContext.createSSLEngine();
                        engine.setUseClientMode(false);
                        final SslHandler sslHandler = new SslHandler(engine);
                        
                        ChannelPipeline pipeline = ch.pipeline();
                        pipeline.addLast("ssl", sslHandler);
                    //pipeline.addFirst("metrics", new BytesMetricsHandler(m_metricsCollector));
                        pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
                        pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
                        //pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
                        pipeline.addLast("decoder", new MQTTDecoder());
                        pipeline.addLast("encoder", new MQTTEncoder());
                        pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
                        pipeline.addLast("handler", handler);
                    }
                })
                .option(ChannelOption.SO_BACKLOG, 128)
                .option(ChannelOption.SO_REUSEADDR, true)
                .childOption(ChannelOption.SO_KEEPALIVE, true);
        try {
            // Bind and start to accept incoming connections.
//            ChannelFuture f = b.bind(Constants.PORT);
            ChannelFuture f = b.bind(props.getProperty("host"), sslPort);
            Log.info("Server binded");
            f.sync();
        } catch (InterruptedException ex) {
            Log.error(null, ex);
        }
    }
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:78,代码来源:NettyAcceptor.java

示例12: ConfigurationParser

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
ConfigurationParser() {
    m_properties.put("port", Integer.toString(Constants.PORT));
    m_properties.put("host", Constants.HOST);
    m_properties.put("password_file", "");
}
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:6,代码来源:ConfigurationParser.java

示例13: initialize

import org.dna.mqtt.commons.Constants; //导入依赖的package包/类
public void initialize(IMessaging messaging) throws IOException {
        DemuxingProtocolDecoder decoder = new DemuxingProtocolDecoder();
        decoder.addMessageDecoder(new ConnectDecoder());
        decoder.addMessageDecoder(new PublishDecoder());
        decoder.addMessageDecoder(new PubAckDecoder());
        decoder.addMessageDecoder(new PubRelDecoder());
        decoder.addMessageDecoder(new PubRecDecoder());
        decoder.addMessageDecoder(new PubCompDecoder());
        decoder.addMessageDecoder(new SubscribeDecoder());
        decoder.addMessageDecoder(new UnsubscribeDecoder());
        decoder.addMessageDecoder(new DisconnectDecoder());
        decoder.addMessageDecoder(new PingReqDecoder());
        
        DemuxingProtocolEncoder encoder = new DemuxingProtocolEncoder();
//        encoder.addMessageEncoder(ConnectMessage.class, new ConnectEncoder());
        encoder.addMessageEncoder(ConnAckMessage.class, new ConnAckEncoder());
        encoder.addMessageEncoder(SubAckMessage.class, new SubAckEncoder());
        encoder.addMessageEncoder(UnsubAckMessage.class, new UnsubAckEncoder());
        encoder.addMessageEncoder(PubAckMessage.class, new PubAckEncoder());
        encoder.addMessageEncoder(PubRecMessage.class, new PubRecEncoder());
        encoder.addMessageEncoder(PubCompMessage.class, new PubCompEncoder());
        encoder.addMessageEncoder(PubRelMessage.class, new PubRelEncoder());
        encoder.addMessageEncoder(PublishMessage.class, new PublishEncoder());
        encoder.addMessageEncoder(PingRespMessage.class, new PingRespEncoder());
        
        m_acceptor = new NioSocketAcceptor();
        
        m_acceptor.getFilterChain().addLast( "logger", new MQTTLoggingFilter("SERVER LOG") );
        m_acceptor.getFilterChain().addLast( "codec", new ProtocolCodecFilter(encoder, decoder));
        
        MinaMQTTHandler handler = new MinaMQTTHandler();
        
        handler.setMessaging(messaging);
        
        m_acceptor.setHandler(handler);
        ((NioSocketAcceptor)m_acceptor).setReuseAddress(true);
        ((NioSocketAcceptor)m_acceptor).getSessionConfig().setReuseAddress(true);
        m_acceptor.getSessionConfig().setReadBufferSize( 2048 );
        m_acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, Constants.DEFAULT_CONNECT_TIMEOUT );
        m_acceptor.getStatistics().setThroughputCalculationInterval(10);
        m_acceptor.getStatistics().updateThroughput(System.currentTimeMillis());
        m_acceptor.bind( new InetSocketAddress(Constants.PORT) );
        LOG.info("Server binded");
    }
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:45,代码来源:MinaAcceptor.java


注:本文中的org.dna.mqtt.commons.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。