Java Code Examples for org.fisco.bcos.channel.client.Service#setPushCallback()
The following examples show how to use
org.fisco.bcos.channel.client.Service#setPushCallback() .
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 |
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 |
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(); }
Example 3
Source File: Channel2ServerNeedVerify.java From web3sdk with Apache License 2.0 | 5 votes |
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); service.setNeedVerifyTopics(topic); 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 4
Source File: AMOPChannel.java From WeEvent with Apache License 2.0 | 4 votes |
public void subTopic(String topic, String groupId, BufferedInputStream privatePem, WeEventFileClient.EventListener eventListener) throws BrokerException { if (this.senderTopics.contains(topic) || senderVerifyTopics.containsKey(topic)) { log.error("this is already sender side for topic: {}", topic); throw new BrokerException(ErrorCode.FILE_SENDER_RECEIVER_CONFLICT); } Service service = Web3SDKConnector.initService(Long.valueOf(groupId), this.fileTransportService.getFiscoConfig()); // construct attribute for service AMOPVerifyTopicToKeyInfo verifyTopicToKeyInfo = new AMOPVerifyTopicToKeyInfo(); ConcurrentHashMap<String, AMOPVerifyKeyInfo> topicToKeyInfo = new ConcurrentHashMap<>(); AMOPVerifyKeyInfo verifyKeyInfo = new AMOPVerifyKeyInfo(); // set private pem for service InputStreamResource inputStreamResource = new InputStreamResource(privatePem); verifyKeyInfo.setPrivateKey(inputStreamResource); topicToKeyInfo.put(topic, verifyKeyInfo); verifyTopicToKeyInfo.setTopicToKeyInfo(topicToKeyInfo); // set service attribute service.setTopic2KeyInfo(verifyTopicToKeyInfo); service.setNeedVerifyTopics(topic); service.setPushCallback(this); // run service try { service.run(); } catch (Exception e) { log.error("service run failed", e); throw new BrokerException(ErrorCode.WEB3SDK_INIT_SERVICE_ERROR); } service.updateTopicsToNode(); log.info("subscribe verify topic on AMOP channel, {}", topic); this.topicListenerMap.put(topic, eventListener); // put <topic-service> to map in AMOPChannel this.subVerifyTopics.put(topic, service); }