use of com.github.dreamhead.moco.SocketRequest in project moco by dreamhead.
the class MocoSocketHandler method channelRead0.
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final ByteBuf msg) {
MessageContent content = content().withContent(new ByteBufInputStream(msg)).build();
SocketRequest request = new DefaultSocketRequest(content);
SessionContext context = new SessionContext(request, new DefaultSocketResponse());
Optional<Response> response = server.getResponse(context);
Response actual = response.orElseThrow(() -> new MocoException(format("No handler found for request: %s", context.getRequest().getContent())));
ctx.write(ByteBufs.toByteBuf(actual.getContent().getContent()));
}
Aggregations