All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bdware.doip.audit.writer.ClientContext Maven / Gradle / Ivy

The newest version!
package org.bdware.doip.audit.writer;

import io.netty.channel.Channel;
import org.bdware.doip.audit.client.DoIdWrapper;

public class ClientContext extends EndpointContext {

    private final Channel channel;
    private final DoIdWrapper serverDoid;
    private final DoIdWrapper clientDoid;

    public ClientContext(DoIdWrapper clientDoid, DoIdWrapper serverDoid, Channel channel) {
        this.channel = channel;
        this.serverDoid = serverDoid;
        this.clientDoid = clientDoid;
    }

    @Override
    public String getClientIP() {
        try {
            return extractIP(channel.localAddress());
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public String getClientDoId() {
        if (clientDoid != null) return clientDoid.getDoId();
        return null;
    }

    @Override
    public String getServerIP() {
        try {
            return extractIP(channel.remoteAddress());
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public String getServerDoId() {
        if (serverDoid != null) return serverDoid.getDoId();
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy