Search in sources :

Example 1 with TestPacket

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"));
}
Also used : TestPacket(de.datasecs.hydra.shared.TestPacket) StandardPacket(de.datasecs.hydra.shared.protocol.packets.StandardPacket) PacketHandler(de.datasecs.hydra.shared.protocol.packets.listener.PacketHandler)

Example 2 with TestPacket

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
}
Also used : TestPacket(de.datasecs.hydra.shared.TestPacket)

Aggregations

TestPacket (de.datasecs.hydra.shared.TestPacket)2 StandardPacket (de.datasecs.hydra.shared.protocol.packets.StandardPacket)1 PacketHandler (de.datasecs.hydra.shared.protocol.packets.listener.PacketHandler)1