/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * <p>Closes all client connections currently connected gracefully.</p> * * <p>Note that this does <i>not</i> settle the actual payment channels (and broadcast payment transactions), which * must be done using the {@link StoredPaymentChannelServerStates} which manages the states for the associated * wallet.</p> */ public void close() { server.stopAsync(); server.awaitTerminated(); } }
final SettableFuture<Protos.TwoWayChannelMessage> clientMessage1Received = SettableFuture.create(); final SettableFuture<Protos.TwoWayChannelMessage> clientMessage2Received = SettableFuture.create(); NioServer server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { server.startAsync(); server.awaitRunning(); clientConnectionClosed.get(); server.stopAsync(); server.awaitTerminated(); assertFalse(server.isRunning());
final SettableFuture<Void> serverConnection2Closed = SettableFuture.create(); final SettableFuture<Void> clientConnection2Closed = SettableFuture.create(); NioServer server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { server.startAsync(); server.awaitRunning(); serverConnection2Closed.get(); server.stopAsync(); server.awaitTerminated();
final SettableFuture<Protos.TwoWayChannelMessage> client2MessageReceived = SettableFuture.create(); final SettableFuture<Protos.TwoWayChannelMessage> client3MessageReceived = SettableFuture.create(); NioServer server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { server.startAsync(); server.awaitRunning(); server.stopAsync(); server.selector.wakeup(); client3.closeConnection(); serverConnectionClosed3.get(); server.stopAsync(); server.awaitTerminated(); client2ConnectionClosed.get(); serverConnectionClosed2.get(); server.stopAsync(); server.awaitTerminated();
/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * <p>Closes all client connections currently connected gracefully.</p> * * <p>Note that this does <i>not</i> settle the actual payment channels (and broadcast payment transactions), which * must be done using the {@link StoredPaymentChannelServerStates} which manages the states for the associated * wallet.</p> */ public void close() { server.stopAsync(); server.awaitTerminated(); } }
final SettableFuture<Void> serverConnectionClosed = SettableFuture.create(); final SettableFuture<Void> client2Disconnected = SettableFuture.create(); NioServer server = new NioServer(new StreamConnectionFactory() { boolean finishedFirst = false; @Override server.startAsync(); server.awaitRunning(); client2Disconnected.get(); server.stopAsync().awaitTerminated();
/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * <p>Closes all client connections currently connected gracefully.</p> * * <p>Note that this does <i>not</i> settle the actual payment channels (and broadcast payment transactions), which * must be done using the {@link StoredPaymentChannelServerStates} which manages the states for the associated * wallet.</p> */ public void close() { server.stopAsync(); server.awaitTerminated(); } }
final SettableFuture<Protos.TwoWayChannelMessage> clientMessage3Received = SettableFuture.create(); final SettableFuture<Protos.TwoWayChannelMessage> clientMessage4Received = SettableFuture.create(); NioServer server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { server.startAsync(); server.awaitRunning(); clientConnectionClosed.get(); server.stopAsync(); server.awaitTerminated();
/** * Binds to the given port and starts accepting new client connections. * @throws Exception If binding to the given port fails (eg SocketException: Permission denied for privileged ports) */ public void bindAndStart(int port) throws Exception { server = new NioServer(new StreamConnectionFactory() { @Override public ProtobufConnection<Protos.TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) { return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler; } }, new InetSocketAddress(port)); server.startAsync(); server.awaitRunning(); }
/** * <p>Closes all client connections currently connected gracefully.</p> * * <p>Note that this does <i>not</i> settle the actual payment channels (and broadcast payment transactions), which * must be done using the {@link StoredPaymentChannelServerStates} which manages the states for the associated * wallet.</p> */ public void close() { server.stopAsync(); server.awaitTerminated(); } }
protected void startPeerServer(int i) throws IOException { peerServers[i] = new NioServer(new StreamConnectionFactory() { @Nullable @Override public StreamConnection getNewConnection(InetAddress inetAddress, int port) { return new InboundMessageQueuer(PARAMS) { @Override public void connectionClosed() { } @Override public void connectionOpened() { newPeerWriteTargetQueue.offer(this); } }; } }, new InetSocketAddress("127.0.0.1", 2000 + i)); peerServers[i].startAsync(); peerServers[i].awaitRunning(); }
protected void stopPeerServer(int i) { peerServers[i].stopAsync(); peerServers[i].awaitTerminated(); }