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:
Abhinab Kanrar 2017-08-21 17:55:21 +05:30 committed by Grzegorz Piwowarek
parent def5758f0a
commit 82c8d88886
1 changed files with 13 additions and 9 deletions

View File

@ -16,15 +16,7 @@ public class SocketServer {
public static void main(String[] args) { public static void main(String[] args) {
Undertow server = Undertow.builder().addHttpListener(8080, "localhost") Undertow server = Undertow.builder().addHttpListener(8080, "localhost")
.setHandler(path().addPrefixPath("/baeldungApp", websocket((exchange, channel) -> { .setHandler(path().addPrefixPath("/baeldungApp", websocket((exchange, channel) -> {
channel.getReceiveSetter().set(new AbstractReceiveListener() { channel.getReceiveSetter().set(getListener());
@Override
protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) {
final String messageData = message.getData();
for (WebSocketChannel session : channel.getPeerConnections()) {
WebSockets.sendText(messageData, session, null);
}
}
});
channel.resumeReceives(); channel.resumeReceives();
})).addPrefixPath("/", resource(new ClassPathResourceManager(SocketServer.class.getClassLoader(), })).addPrefixPath("/", resource(new ClassPathResourceManager(SocketServer.class.getClassLoader(),
SocketServer.class.getPackage())).addWelcomeFiles("index.html"))) SocketServer.class.getPackage())).addWelcomeFiles("index.html")))
@ -33,4 +25,16 @@ public class SocketServer {
server.start(); 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);
}
}
};
}
} }