Search in sources :

Example 26 with Packet

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

the class DecoderMessagePacketTest method testDecode.

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

Example 27 with Packet

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

the class EncoderAckPacketTest method testEncode.

@Test
public void testEncode() throws IOException {
    Packet packet = new Packet(PacketType.ACK);
    packet.setAckId(140L);
    ByteBuf result = Unpooled.buffer();
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("6:::140", result.toString(CharsetUtil.UTF_8));
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 28 with Packet

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

the class EncoderConnectionPacketTest method testEncodeDisconnection.

@Test
public void testEncodeDisconnection() throws IOException {
    Packet packet = new Packet(PacketType.DISCONNECT);
    packet.setNsp("/woot");
    ByteBuf result = Unpooled.buffer();
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("0::/woot", result.toString(CharsetUtil.UTF_8));
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 29 with Packet

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

the class EncoderMessagePacketTest method testEncode.

@Test
public void testEncode() throws IOException {
    Packet packet = new Packet(PacketType.MESSAGE);
    packet.setData("woot");
    ByteBuf result = Unpooled.buffer();
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("3:::woot", result.toString(CharsetUtil.UTF_8));
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 30 with Packet

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

the class EncoderMessagePacketTest method testEncodeWithIdAndEndpoint.

@Test
public void testEncodeWithIdAndEndpoint() throws IOException {
    Packet packet = new Packet(PacketType.MESSAGE);
    //        packet.setId(5L);
    //        packet.setAck(true);
    packet.setNsp("/tobi");
    ByteBuf result = Unpooled.buffer();
    //        encoder.encodePacket(packet, result);
    Assert.assertEquals("3:5:/tobi", result.toString(CharsetUtil.UTF_8));
}
Also used : Packet(com.corundumstudio.socketio.protocol.Packet) ByteBuf(io.netty.buffer.ByteBuf) 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