use of de.datasecs.hydra.client.TestClientProtocol in project Hydra by DataSecs.
the class HydraTest method init.
public static void init() {
server = new Server.Builder("localhost", 8888, new TestServerProtocol()).addListener(new HydraSessionListener() {
@Override
public void onConnected(Session session) {
System.out.println("TestClient connected!");
synchronized (LOCK) {
clientConnected = true;
LOCK.notify();
}
}
@Override
public void onDisconnected(Session session) {
System.out.println("TestClient disconnected!");
}
}).option(ChannelOption.SO_BACKLOG, 200).childOption(ChannelOption.TCP_NODELAY, true).childOption(ChannelOption.SO_KEEPALIVE, true).build();
System.out.println("Server started successfully!");
client = new Client.Builder("localhost", 8888, new TestClientProtocol()).workerThreads(4).option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_KEEPALIVE, true).addSessionListener(new HydraSessionListener() {
@Override
public void onConnected(Session session) {
System.out.println("Connected to server!");
}
@Override
public void onDisconnected(Session session) {
System.out.println("\nDisconnected from server!");
}
}).build();
System.out.println("Client started successfully!");
}
Aggregations