use of com.robo4j.socket.http.units.ServerContext in project robo4j by Robo4J.
the class DatagramPathUtils method updateDatagramServerContextPaths.
public static void updateDatagramServerContextPaths(final RoboContext context, final ServerContext serverContext, final Collection<HttpPathMethodDTO> paths) {
final Map<PathHttpMethod, ServerPathConfig> resultPaths = paths.stream().map(e -> {
RoboReference<Object> reference = context.getReference(e.getRoboUnit());
return new ServerPathConfig(toPath(SystemPath.UNITS.getPath(), e.getRoboUnit()), reference, e.getMethod(), e.getCallbacks());
}).collect(Collectors.toMap(e -> new PathHttpMethod(e.getPath(), null), e -> e));
serverContext.addPaths(resultPaths);
}
use of com.robo4j.socket.http.units.ServerContext in project robo4j by Robo4J.
the class HttpPathUtils method updateHttpServerContextPaths.
public static void updateHttpServerContextPaths(final RoboContext context, final ServerContext serverContext, final Collection<HttpPathMethodDTO> paths) {
final Map<PathHttpMethod, ServerPathConfig> resultPaths = paths.stream().map(e -> {
RoboReference<Object> reference = context.getReference(e.getRoboUnit());
return HttpPathUtils.toHttpPathConfig(e, reference);
}).collect(Collectors.toMap(e -> new PathHttpMethod(e.getPath(), e.getMethod()), e -> e));
resultPaths.put(new PathHttpMethod(Utf8Constant.UTF8_SOLIDUS, HttpMethod.GET), new ServerPathConfig(Utf8Constant.UTF8_SOLIDUS, null, HttpMethod.GET));
serverContext.addPaths(resultPaths);
}
use of com.robo4j.socket.http.units.ServerContext 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