public static void main(String[] args) { try { SocketChannel socketChannel = SocketChannel.open(); SocketAddress socketAddress = new InetSocketAddress("10.0.1.12", 10741); socketChannel.connect(socketAddress); OrderFactory o = new OrderFactory(); Order order = o.SampleMessgeOrder(); order.getOrderMessage().setOrderLevel("SystemLevelCommand"); order.getOrderMessage().getOrderMethod().getMethod().get(0).setMethodName("systemStop"); order .getOrderMessage() .getOrderMethod() .getMethod() .get(0) .getParameter() .get(0) .setParameter("4"); order .getOrderMessage() .getOrderMethod() .getMethod() .get(0) .getParameter() .get(1) .setParameter("6"); NIOServer.sendData(socketChannel, order); socketChannel.socket().shutdownOutput(); } catch (Exception ex) { System.out.println("me: " + ex.getMessage()); } }
public SentMessageService(String title, String content) { try { SocketChannel socketChannel = SocketChannel.open(); SocketAddress socketAddress = new InetSocketAddress("10.0.1.25", 10240); socketChannel.connect(socketAddress); OrderFactory o = new OrderFactory(); Order order = o.SampleMessgeOrder(); order .getOrderMessage() .getOrderMethod() .getMethod() .get(0) .getParameter() .get(0) .setParameter(title); order .getOrderMessage() .getOrderMethod() .getMethod() .get(0) .getParameter() .get(1) .setParameter(content); NIOServer.sendData(socketChannel, order); socketChannel.socket().shutdownOutput(); } catch (Exception ex) { System.out.println("me: " + ex.getMessage()); } }