use of com.corundumstudio.socketio.MultiTypeAckCallback in project netty-socketio by mrniko.
the class AckManager method onAck.
@SuppressWarnings("unchecked")
public void onAck(SocketIOClient client, Packet packet) {
AckSchedulerKey key = new AckSchedulerKey(Type.ACK_TIMEOUT, client.getSessionId(), packet.getAckId());
scheduler.cancel(key);
AckCallback callback = removeCallback(client.getSessionId(), packet.getAckId());
if (callback == null) {
return;
}
if (callback instanceof MultiTypeAckCallback) {
callback.onSuccess(new MultiTypeArgs(packet.<List<Object>>getData()));
} else {
Object param = null;
List<Object> args = packet.getData();
if (!args.isEmpty()) {
param = args.get(0);
}
if (args.size() > 1) {
log.error("Wrong ack args amount. Should be only one argument, but current amount is: {}. Ack id: {}, sessionId: {}", args.size(), packet.getAckId(), client.getSessionId());
}
callback.onSuccess(param);
}
}
Aggregations