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


Java Server.startServer方法代码示例

本文整理汇总了Java中io.moquette.server.Server.startServer方法的典型用法代码示例。如果您正苦于以下问题:Java Server.startServer方法的具体用法?Java Server.startServer怎么用?Java Server.startServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.moquette.server.Server的用法示例。


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

示例1: startBroker

import io.moquette.server.Server; //导入方法依赖的package包/类
private Server startBroker(Server server, IConfig memoryConfig) {
	try {
		server.startServer(memoryConfig);
		return server;
	} catch (final IOException e) {
		throw propagate(e);
	}
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:9,代码来源:MqttBroker.java

示例2: start

import io.moquette.server.Server; //导入方法依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public synchronized void start() throws Exception {
  long time = log(LOG, "start");
  File mqttServerDirectory = new File(ABS_DIR_MQTT);
  FileUtils.deleteDirectory(mqttServerDirectory);
  mqttServerDirectory.mkdirs();
  mqttServer = new Server();
  Properties mqttServerProperties = new Properties();
  mqttServerProperties.put(PERSISTENT_STORE_PROPERTY_NAME, ABS_DIR_MQTT + File.separatorChar + MQTT_BROKER_STORE_NAME);
  mqttServerProperties.put(PORT_PROPERTY_NAME, "" + MQTT_BROKER_PORT);
  mqttServer.startServer(new MemoryConfig(mqttServerProperties));
  log(LOG, "start", time);
}
 
开发者ID:ggear,项目名称:cloudera-framework,代码行数:15,代码来源:MqttServer.java

示例3: main

import io.moquette.server.Server; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
        IResourceLoader classpathLoader = new ClasspathResourceLoader();
        final IConfig classPathConfig = new ResourceLoaderConfig(classpathLoader);

        final Server mqttBroker = new Server();
        List<? extends InterceptHandler> userHandlers = Collections.singletonList(new PublisherListener());
        mqttBroker.startServer(classPathConfig, userHandlers);

        System.out.println("Broker started press [CTRL+C] to stop");
        //Bind  a shutdown hook
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            System.out.println("Stopping broker");
            mqttBroker.stopServer();
            System.out.println("Broker stopped");
        }));

        Thread.sleep(20000);
        System.out.println("Before self publish");
        MqttPublishMessage message = MqttMessageBuilders.publish()
            .topicName("/exit")
            .retained(true)
//        qos(MqttQoS.AT_MOST_ONCE);
//        qQos(MqttQoS.AT_LEAST_ONCE);
            .qos(MqttQoS.EXACTLY_ONCE)
            .payload(Unpooled.copiedBuffer("Hello World!!".getBytes()))
            .build();

        mqttBroker.internalPublish(message, "INTRLPUB");
        System.out.println("After self publish");
    }
 
开发者ID:andsel,项目名称:moquette,代码行数:31,代码来源:EmbeddedLauncher.java

示例4: onStart

import io.moquette.server.Server; //导入方法依赖的package包/类
@Override
protected void onStart() throws PluginStartupException {

    // load topics from manifest file
    loadTopics();

    mqttBroker = new Server();
    Properties props = new Properties();

    // get properties from manifest file
    props.setProperty(BrokerConstants.PORT_PROPERTY_NAME, Integer.toString(BROKER_PORT));
    props.setProperty(BrokerConstants.HOST_PROPERTY_NAME, BROKER_HOST);

    props.setProperty(BrokerConstants.PASSWORD_FILE_PROPERTY_NAME, Info.PATHS.PATH_DEVICES_FOLDER + "/mqtt-broker/config/password_file.conf");
    props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, Info.PATHS.PATH_DEVICES_FOLDER + "/mqtt-broker/config/moquette_store.mapdb");

    config = new MemoryConfig(props);
    userHandlers = asList(new PublisherListener());

    try {
        mqttBroker.startServer(config, userHandlers);
    } catch (IOException ex) {
        throw new PluginStartupException("Plugin can't start for an IOException.", ex);
    }
    setDescription("MQTT broker listening to " + config.getProperty(BrokerConstants.HOST_PROPERTY_NAME) + ":" + config.getProperty(BrokerConstants.PORT_PROPERTY_NAME));
    LOG.info("MQTT broker plugin started");
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:28,代码来源:MqttBroker.java

示例5: startServer

import io.moquette.server.Server; //导入方法依赖的package包/类
protected void startServer() throws IOException {
    m_server = new Server();
    m_server.startServer();
}
 
开发者ID:andsel,项目名称:moquette,代码行数:5,代码来源:ConnectionIT.java


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