use of com.robo4j.socket.http.units.ClientContext in project robo4j by Robo4J.
the class ChannelUtils method getSocketAddressByContext.
public static SocketAddress getSocketAddressByContext(SocketContext<?> context) {
if (context instanceof ClientContext) {
final String clientHost = context.getPropertySafe(String.class, PROPERTY_HOST);
final int clientPort = context.getPropertySafe(Integer.class, PROPERTY_SOCKET_PORT);
return new InetSocketAddress(clientHost, clientPort);
} else if (context instanceof ServerContext) {
final int serverPort = context.getPropertySafe(Integer.class, PROPERTY_SOCKET_PORT);
return new InetSocketAddress(serverPort);
} else {
throw new SocketException("invalid context" + context);
}
}
Aggregations