org.bdware.doip.audit.client.AuditDoipClientHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
package org.bdware.doip.audit.client;
import io.netty.channel.ChannelHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.writer.AuditConfig;
import org.bdware.doip.audit.writer.AuditLogPool;
import org.bdware.doip.audit.writer.ClientContext;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.client.DoipMessageCallback;
import org.bdware.doip.endpoint.client.NettyDoipClientHandler;
@ChannelHandler.Sharable
public class AuditDoipClientHandler extends NettyDoipClientHandler {
static Logger LOGGER = LogManager.getLogger(AuditDoipClientHandler.class);
private final DoIdWrapper clientDoId;
private final DoIdWrapper serverDoId;
AuditLogPool pool;
public AuditDoipClientHandler(DoIdWrapper clientDoIdWrapper, DoIdWrapper serverDoIdWrapper, AuditConfig config) {
pool = new AuditLogPool(config.createLogWriterInstance());
this.clientDoId = clientDoIdWrapper;
this.serverDoId = serverDoIdWrapper;
}
@Override
public void sendMessage(final DoipMessage request, DoipMessageCallback callback, int timeoutSeconds) {
super.sendMessage(request, new DoipMessageCallback() {
@Override
public void onResult(DoipMessage msg) {
ClientContext context = new ClientContext(clientDoId, serverDoId, channel);
pool.extract(context, request, msg);
callback.onResult(msg);
}
}, timeoutSeconds);
}
}