Java Code Examples for org.fisco.bcos.channel.client.Service#setTopics()

The following examples show how to use org.fisco.bcos.channel.client.Service#setTopics() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Channel2Server.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.out.println("Param: topic");
        return;
    }
    String topic = args[0];
    logger.debug("init Server");
    ApplicationContext context =
            new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
    Service service = context.getBean(Service.class);
    Set<String> topics = new HashSet<String>();
    topics.add(topic);
    service.setTopics(topics);
    PushCallback cb = new PushCallback();
    service.setPushCallback(cb);
    System.out.println("3s...");
    Thread.sleep(1000);
    System.out.println("2s...");
    Thread.sleep(1000);
    System.out.println("1s...");
    Thread.sleep(1000);

    System.out.println("start test");
    System.out.println("===================================================================");

    service.run();
}
 
Example 2
Source File: Channel2ServerUpdateTopics.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.out.println("Param: topic");
        return;
    }
    String topic = args[0];
    logger.debug("init Server");
    ApplicationContext context =
            new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
    Service service = context.getBean(Service.class);
    PushCallback cb = new PushCallback();
    service.setPushCallback(cb);
    System.out.println("3s...");
    Thread.sleep(1000);
    System.out.println("2s...");
    Thread.sleep(1000);
    System.out.println("1s...");
    Thread.sleep(1000);

    System.out.println("start test");
    System.out.println("===================================================================");
    service.run();

    Thread.sleep(10000);

    System.out.println("set topics");
    System.out.println("===================================================================");
    Set<String> topics = new HashSet<String>();
    topics.add(topic);
    service.setTopics(topics);
    service.updateTopicsToNode();
}