Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yamass committed Jun 9, 2022
1 parent 81639d8 commit 79d5474
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ export class ReconnectingCompressingWebSocketConnection {
this.closed = true;
}

public close() {
this.stopReconnecting();
this.connection.close();
}

private static log(message: string) {
console.log("Connection: " + message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -19,8 +19,6 @@
*/
package org.teamapps.server.jetty.embedded;

import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import org.teamapps.icon.material.MaterialIcon;
import org.teamapps.ux.component.field.MultiLineTextField;
import org.teamapps.ux.component.rootpanel.RootPanel;
Expand All @@ -40,26 +38,6 @@ public static void main(String[] args) throws Exception {
};

TeamAppsJettyEmbeddedServer jettyServer = new TeamAppsJettyEmbeddedServer(controller, 8082);

jettyServer.addServletContextListener(new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent sce) {

}

@Override
public void contextDestroyed(ServletContextEvent sce) {

}
});

// Test custom configurations:
// jettyServer.configureHttpsUsingP12File(8443, new File("/path/to/cert.p12"), "changeit");
// jettyServer.getWebapp().getSessionHandler().setSecureRequestOnly(true);
// jettyServer.getWebapp().getSessionHandler().getSessionCookieConfig().setHttpOnly(true);
// jettyServer.getWebapp().getSessionHandler().getSessionCookieConfig().setComment("__SAME_SITE_STRICT__");

// start server
jettyServer.start();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;

public class WebSocketCommunicationEndpoint extends Endpoint {

private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketCommunicationEndpoint.class);

/**
* This is needed due to https://github.com/eclipse/jetty.project/issues/8151.
* TODO: remove once the ticket is fixed.
*/
private final Executor jettyWorkaroundCloseExecutor = Executors.newFixedThreadPool(5);
private final ObjectMapper mapper = TeamAppsObjectMapperFactory.create();

private final AtomicLong totalSendCount = new AtomicLong();
Expand Down Expand Up @@ -225,7 +232,11 @@ public void sendMessageAsynchronously(AbstractServerMessage msg, SendingErrorHan

@Override
public void close(UiSessionClosingReason closingReason, String message) {
send(new SESSION_CLOSED(closingReason).setMessage(message), WebSocketHandler.this::close, (t) -> WebSocketHandler.this.close());
send(
new SESSION_CLOSED(closingReason).setMessage(message),
() -> jettyWorkaroundCloseExecutor.execute(WebSocketHandler.this::close),
(t) -> jettyWorkaroundCloseExecutor.execute(() -> WebSocketHandler.this.close())
);
}

@Override
Expand Down

0 comments on commit 79d5474

Please sign in to comment.