@Accessible( defaultAccessible = false, accessible = {@Authority(name = "admin")}) public void stopPinging() { Connection connection = ApplicationContextUtil.getBean(ConnectionProvider.class).get(); logger.info(connection.getId()); PingThread pingThread = pingThreads.get(connection); pingThread.running = false; try { pingThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } }
@Accessible( defaultAccessible = false, accessible = {@Authority(name = "admin")}) public void startPinging() { Connection connection = ApplicationContextUtil.getBean(ConnectionProvider.class).get(); logger.info(connection.getId()); RPCService rpcService = ApplicationContextUtil.getBean(RPCService.class); TestClient client = (TestClient) rpcService.getClientInstance("client", connection); PingThread pingThread = new PingThread(client, connection); pingThread.start(); pingThreads.put(connection, pingThread); }
@Override public void run() { while (running) { logger.debug("pinging: " + connection.getId()); client.ping("this is a ping"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
/* * (non-Javadoc) * @see * com.syncnapsis.websockets.service.BaseService#onMessage(com.syncnapsis.websockets.Connection, * java.lang.String) */ @Override public void onMessage(Connection connection, String data) { logger.debug(connection.getId() + ": " + data); try { RPCMessage msg = (RPCMessage) serializer.deserialize(data, new RPCMessage(), getAuthorities()); msg.setConnection(connection); if (msg.getScid() != null) this.onResult(msg); else this.onRPC(msg); } catch (DeserializationException e) { logger.error("Error deserializing message!", e); } }
private void print(String message) { Connection connection = ApplicationContextUtil.getBean(ConnectionProvider.class).get(); logger.info(connection.getId() + ": " + message); }