Skip to content

Commit 82c8d88

Browse files
AbhinabKanrarpivovarit
authored andcommitted
simplifying (eugenp#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
1 parent def5758 commit 82c8d88

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

‎undertow/src/main/java/com/baeldung/undertow/socket/SocketServer.java‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ public class SocketServer {
1616
public static void main(String[] args) {
1717
Undertow server = Undertow.builder().addHttpListener(8080, "localhost")
1818
.setHandler(path().addPrefixPath("/baeldungApp", websocket((exchange, channel) -> {
19-
channel.getReceiveSetter().set(new AbstractReceiveListener() {
20-
@Override
21-
protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) {
22-
final String messageData = message.getData();
23-
for (WebSocketChannel session : channel.getPeerConnections()) {
24-
WebSockets.sendText(messageData, session, null);
25-
}
26-
}
27-
});
19+
channel.getReceiveSetter().set(getListener());
2820
channel.resumeReceives();
2921
})).addPrefixPath("/", resource(new ClassPathResourceManager(SocketServer.class.getClassLoader(),
3022
SocketServer.class.getPackage())).addWelcomeFiles("index.html")))
@@ -33,4 +25,16 @@ protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage m
3325
server.start();
3426
}
3527

28+
private static AbstractReceiveListener getListener() {
29+
return new AbstractReceiveListener() {
30+
@Override
31+
protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) {
32+
final String messageData = message.getData();
33+
for (WebSocketChannel session : channel.getPeerConnections()) {
34+
WebSockets.sendText(messageData, session, null);
35+
}
36+
}
37+
};
38+
}
39+
3640
}

0 commit comments

Comments
 (0)