public static void main(String[] args) throws URISyntaxException, IOException { HproseTcpServer server = new HproseTcpServer("tcp://0.0.0.0:8080"); server.publish("time"); server.start(); Timer timer = new Timer(() -> server.push("time", Calendar.getInstance())); timer.setInterval(1000); System.out.println("START"); System.in.read(); server.stop(); System.out.println("STOP"); }
@Override public void afterPropertiesSet() throws Exception { checkService(); checkServiceInterface(); Object service = getService(); Class cls = getServiceInterface(); tcpServer = new HproseTcpServer(host, port); tcpServer.add(service, cls); tcpServer.setDebugEnabled(debug); tcpServer.setEvent(event); tcpServer.setMode(mode); tcpServer.setFilter(filter); tcpServer.use(invokeHandler); tcpServer.beforeFilter.use(beforeFilterHandler); tcpServer.afterFilter.use(afterFilterHandler); }
public void stop() { tcpServer.stop(); }
public void start() throws IOException { tcpServer.start(); }