New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Server extend Action<ServerTransport> #68
Comments
If server implementation is provided per layer, it would solve the above problem. That is, However, since Discussion
This issue will focus on the first question. |
On second thought after reviewing
Then, a bootstrap code will look like: // consumes transport and produces socket
Server server = new DefaultServer();
server.socketAction(socket -> {});
// consumes http and produces transport
HttpTransportServer httpTransportServer = new HttpTransportServer();
httpTransportServer.transportAction(server);
// consumes ws and produces transport
WebSocketTransportServer wsTransportServer = new WebSocketTransportServer();
wsTransportServer.transportAction(server);
// How to integrate with user-defined transport
server.on((NetServerTransport) transport);
// Atmosphere 2
ServletContext context = event.getServletContext();
ServletRegistration.Dynamic reg = context.addServlet(VibeAtmosphereServlet.class.getName(), new VibeAtmosphereServlet() {
@Override
protected Action<ServerHttpExchange> httpAction() {
return httpTransportServer;
}
@Override
protected Action<ServerWebSocket> wsAction() {
return wsTransportServer;
}
});
reg.setAsyncSupported(true);
reg.setInitParameter(ApplicationConfig.DISABLE_ATMOSPHEREINTERCEPTOR, Boolean.TRUE.toString());
reg.addMapping("/vibe"); |
Some tasks are moved to #71 |
In fact,
1
can replaceserver.httpAction
andserver.wsAction
then2
is not needed. See the following snippet:Although the second one shows what input and output of each component are more clearly than the first one, since user doesn't need to know about
Transport
, it would be better to provide httpAction and wsAction (so to hide transport) as is for convenience. But I'm not sure. Anyway, internally it already works like the second one.The text was updated successfully, but these errors were encountered: