simplifying (#2476)
* moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression * jooby project * jooby project * reducing employee bean content * bootique module * bootique * bootique * undertow module * undertow module * refactoring * using lambda * as per baeldung formatter * easy code added for simplicity * simpliflying
This commit is contained in:
parent
def5758f0a
commit
82c8d88886
|
@ -16,15 +16,7 @@ public class SocketServer {
|
|||
public static void main(String[] args) {
|
||||
Undertow server = Undertow.builder().addHttpListener(8080, "localhost")
|
||||
.setHandler(path().addPrefixPath("/baeldungApp", websocket((exchange, channel) -> {
|
||||
channel.getReceiveSetter().set(new AbstractReceiveListener() {
|
||||
@Override
|
||||
protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) {
|
||||
final String messageData = message.getData();
|
||||
for (WebSocketChannel session : channel.getPeerConnections()) {
|
||||
WebSockets.sendText(messageData, session, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
channel.getReceiveSetter().set(getListener());
|
||||
channel.resumeReceives();
|
||||
})).addPrefixPath("/", resource(new ClassPathResourceManager(SocketServer.class.getClassLoader(),
|
||||
SocketServer.class.getPackage())).addWelcomeFiles("index.html")))
|
||||
|
@ -33,4 +25,16 @@ public class SocketServer {
|
|||
server.start();
|
||||
}
|
||||
|
||||
private static AbstractReceiveListener getListener() {
|
||||
return new AbstractReceiveListener() {
|
||||
@Override
|
||||
protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) {
|
||||
final String messageData = message.getData();
|
||||
for (WebSocketChannel session : channel.getPeerConnections()) {
|
||||
WebSockets.sendText(messageData, session, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue