use of de.datasecs.hydra.shared.TestPacket in project Hydra by DataSecs.
the class TestServerPacketListener method onTestPacket.
@PacketHandler
public void onTestPacket(TestPacket examplePacket, Session session) {
Assertions.assertTrue(session.isConnected());
switch(examplePacket.getNumber()) {
case 0:
Assertions.assertEquals("Test", examplePacket.getObject().toString());
break;
}
session.send(new StandardPacket("#Received!"));
session.send(new TestPacket(examplePacket.getNumber(), "test"));
}
use of de.datasecs.hydra.shared.TestPacket in project Hydra by DataSecs.
the class HydraTest method testClient.
public static void testClient() {
Assertions.assertTrue(client.isConnected());
Assertions.assertTrue(client.getChannel().isWritable());
Assertions.assertTrue(client.getChannel().isOpen());
Assertions.assertThrows(IllegalStateException.class, client::connect);
Assertions.assertNotNull(client.getSession());
// String test
client.send(new TestPacket(1, "Test"));
// (String) array test
String[] testArray = new String[1000];
for (int i = 0; i < 1000; i++) {
testArray[i] = String.format("test%d", i);
}
client.send(new TestPacket(2, testArray));
// Custom class test
// Finish test, when okay is received, realize with synchronized
}
Aggregations