use of com.corundumstudio.socketio.protocol.PacketDecoder 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));
}
use of com.corundumstudio.socketio.protocol.PacketDecoder in project netty-socketio by mrniko.
the class SocketIOChannelInitializer method start.
public void start(Configuration configuration, NamespacesHub namespacesHub) {
this.configuration = configuration;
ackManager = new AckManager(scheduler);
JsonSupport jsonSupport = configuration.getJsonSupport();
PacketEncoder encoder = new PacketEncoder(configuration, jsonSupport);
PacketDecoder decoder = new PacketDecoder(jsonSupport, ackManager);
String connectPath = configuration.getContext() + "/";
boolean isSsl = configuration.getKeyStore() != null;
if (isSsl) {
try {
sslContext = createSSLContext(configuration);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
StoreFactory factory = configuration.getStoreFactory();
authorizeHandler = new AuthorizeHandler(connectPath, scheduler, configuration, namespacesHub, factory, this, ackManager, clientsBox);
factory.init(namespacesHub, authorizeHandler, jsonSupport);
xhrPollingTransport = new PollingTransport(decoder, authorizeHandler, clientsBox);
webSocketTransport = new WebSocketTransport(isSsl, authorizeHandler, configuration, scheduler, clientsBox);
PacketListener packetListener = new PacketListener(ackManager, namespacesHub, xhrPollingTransport, scheduler);
packetHandler = new InPacketHandler(packetListener, decoder, namespacesHub, configuration.getExceptionListener());
try {
encoderHandler = new EncoderHandler(configuration, encoder);
} catch (Exception e) {
throw new IllegalStateException(e);
}
wrongUrlHandler = new WrongUrlHandler();
}
Aggregations