use of de.datasecs.hydra.example.shared.serialization.CustomClass in project Hydra by DataSecs.
the class ExampleSerializationClient method main.
public static void main(String[] args) {
HydraClient client = new Client.Builder("localhost", 8888, new ExampleSerializationClientProtocol()).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();
if (client.isConnected()) {
session = client.getSession();
System.out.println("\nClient is online!");
System.out.printf("Socket address: %s%n", session.getAddress());
}
// Create custom classes and necessary stuff for example serialization
List<String> testStringList = new ArrayList<>();
testStringList.add("Hydra");
testStringList.add("Serialization");
testStringList.add("Test");
CustomClassExtended customClassExtended = new CustomClassExtended("testStringExtended", UUID.randomUUID(), 5L, Integer.class);
CustomClass customClass = new CustomClass("testString", 1, new String[] { "Hydra", "serialization" }, testStringList, "this is a random object", customClassExtended);
// Sends the instance of a custom class, that is create and filled with data above
session.send(new ExampleSerializationPacket(customClass));
}
Aggregations