Closed OuIChien closed 10 years ago
Could you send me a client invocation example for this event type?
Hi,mrniko,I use nkzawa/socket.io-client.java And I add the following codes into WebSocketTransport#channelRead()
else if (msg instanceof BinaryWebSocketFrame) { BinaryWebSocketFrame frame = (BinaryWebSocketFrame) msg; ClientHead client = clientsBox.get(ctx.channel()); if (client == null) { log.debug("Client with was already disconnected. Channel closed!"); ctx.channel().close(); frame.release(); return; } ctx.pipeline().fireChannelRead(new PacketsMessage(client, frame.content(), Transport.WEBSOCKET)); frame.release(); }
also I add the following into PacketDecoder#decode if (packet.getSubType() == PacketType.BINARY_EVENT) .........
fixed. Please check
Hi @OuIChien We are using nkzawa/socket.io-client.java client too! How are you sending messages from client to server? Our netty-socketio event listeners don't receive the messages we are sending, to send a message from nkzawa client we use socket.emit("event name", "message"); Thanks !!!
@marshhxx ,my codes:
Client:
IO.Options opts = new IO.Options();
opts.transports = new String[] {WebSocket.NAME};
socket = IO.socket("http://xxx.xxx.xxx:xxxx", opts);
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log.trace("connected!");
try {
// send a message
socket.emit(ActionType.Auth, MyPOJOMapper.toJson(token, false), new Ack() {
@Override
public void call(Object... args) {
if ((Boolean) args[0])
log.trace("authed!");
else
log.trace("auth failed!");
}
});
} catch (IOException e) {
log.error("Auth error", e);
}
}
})
Server:
Configuration config = new Configuration();
config.setMaxFramePayloadLength((int)(1024 * 1024 * 1.5));
config.setMaxHttpContentLength(config.getMaxFramePayloadLength());
config.setHostname(hostname);
config.setPort(port);
server = new SocketIOServer(config);
server.addListeners(connectionListener);
server.addListeners(authListener); // Receive a message from client
AuthListener:
@OnEvent(ActionType.Auth)
private void onAuthEvent(SocketIOClient client, String token, AckRequest ackSender) throws Exception {
// do something...
ackSender.sendAckData(true); // call back
}
they work very well
Hi,mrniko, Is there no BINARY_EVENT implements? I CAN'T found any usage about it in whole project src.