Search in sources :

Example 21 with Packet

use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.

the class DecoderAckPacketTest method testDecodeWithArgs.

@Test
public void testDecodeWithArgs() throws IOException {
    initExpectations();
    Packet packet = decoder.decodePacket("6:::12+[\"woot\",\"wa\"]", null);
    Assert.assertEquals(PacketType.ACK, packet.getType());
    Assert.assertEquals(12, (long) packet.getAckId());
//        Assert.assertEquals(Arrays.<Object>asList("woot", "wa"), packet.getArgs());
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) Test(org.junit.Test)

Example 22 with Packet

use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.

the class DecoderEventPacketTest method testDecodeWithData.

@Test
public void testDecodeWithData() throws IOException {
    JacksonJsonSupport jsonSupport = new JacksonJsonSupport();
    jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class);
    PacketDecoder decoder = new PacketDecoder(jsonSupport, ackManager);
    Packet packet = decoder.decodePacket("5:::{\"name\":\"edwald\",\"args\":[{\"a\": \"b\"},2,\"3\"]}", null);
    Assert.assertEquals(PacketType.EVENT, packet.getType());
    Assert.assertEquals("edwald", packet.getName());
//        Assert.assertEquals(3, packet.getArgs().size());
//        Map obj = (Map) packet.getArgs().get(0);
//        Assert.assertEquals("b", obj.get("a"));
//        Assert.assertEquals(2, packet.getArgs().get(1));
//        Assert.assertEquals("3", packet.getArgs().get(2));
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) PacketDecoder(com.corundumstudio.socketio.protocol.PacketDecoder) JacksonJsonSupport(com.corundumstudio.socketio.protocol.JacksonJsonSupport) Test(org.junit.Test)

Example 23 with Packet

use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.

the class DecoderJsonPacketTest method testUTF8Decode.

@Test
public void testUTF8Decode() throws IOException {
    Packet packet = decoder.decodePacket("4:::\"Привет\"", null);
    //        Assert.assertEquals(PacketType.JSON, packet.getType());
    Assert.assertEquals("Привет", packet.getData());
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) Test(org.junit.Test)

Example 24 with Packet

use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.

the class DecoderJsonPacketTest method testDecode.

@Test
public void testDecode() throws IOException {
    Packet packet = decoder.decodePacket("4:::\"2\"", null);
    //        Assert.assertEquals(PacketType.JSON, packet.getType());
    Assert.assertEquals("2", packet.getData());
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) Test(org.junit.Test)

Example 25 with Packet

use of com.corundumstudio.socketio.protocol.Packet in project netty-socketio by mrniko.

the class DecoderMessagePacketTest method testDecodeId.

@Test
public void testDecodeId() throws IOException {
    Packet packet = decoder.decodePacket("3:1::asdfasdf", null);
    Assert.assertEquals(PacketType.MESSAGE, packet.getType());
//        Assert.assertEquals(1, (long)packet.getId());
//        Assert.assertTrue(packet.getArgs().isEmpty());
//        Assert.assertTrue(packet.getAck().equals(Boolean.TRUE));
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) Test(org.junit.Test)

Aggregations

Packet (com.corundumstudio.socketio.protocol.Packet)39 Test (org.junit.Test)27 ByteBuf (io.netty.buffer.ByteBuf)15 Namespace (com.corundumstudio.socketio.namespace.Namespace)2 AuthPacket (com.corundumstudio.socketio.protocol.AuthPacket)2 HandshakeData (com.corundumstudio.socketio.HandshakeData)1 SocketIOClient (com.corundumstudio.socketio.SocketIOClient)1 Transport (com.corundumstudio.socketio.Transport)1 HttpErrorMessage (com.corundumstudio.socketio.messages.HttpErrorMessage)1 JacksonJsonSupport (com.corundumstudio.socketio.protocol.JacksonJsonSupport)1 PacketDecoder (com.corundumstudio.socketio.protocol.PacketDecoder)1 ConnectMessage (com.corundumstudio.socketio.store.pubsub.ConnectMessage)1 NamespaceClient (com.corundumstudio.socketio.transport.NamespaceClient)1 Channel (io.netty.channel.Channel)1 ChannelFuture (io.netty.channel.ChannelFuture)1 DefaultHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse)1 HttpResponse (io.netty.handler.codec.http.HttpResponse)1 BinaryWebSocketFrame (io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame)1 TextWebSocketFrame (io.netty.handler.codec.http.websocketx.TextWebSocketFrame)1 WebSocketFrame (io.netty.handler.codec.http.websocketx.WebSocketFrame)1