mirror of
https://github.com/Vale54321/schafkopf-bot.git
synced 2025-12-16 03:39:34 +01:00
edited stuff (#50)
This commit is contained in:
committed by
GitHub
parent
b8b89ee696
commit
2e5a42b6d3
@@ -48,13 +48,15 @@ public class BackendServer implements MessageSender {
|
||||
// Configure CORS settings
|
||||
configureCors(context);
|
||||
|
||||
URL webContentUrl = getClass().getClassLoader().getResource("web-content");
|
||||
if (webContentUrl == null) {
|
||||
throw new RuntimeException("Unable to find 'web-content' directory");
|
||||
if (openFrontend) {
|
||||
URL webContentUrl = getClass().getClassLoader().getResource("web-content");
|
||||
if (webContentUrl == null) {
|
||||
throw new RuntimeException("Unable to find 'web-content' directory");
|
||||
}
|
||||
String webContentPath = webContentUrl.toExternalForm();
|
||||
context.setResourceBase(webContentPath);
|
||||
context.addServlet(new ServletHolder("frontend", DefaultServlet.class), "/");
|
||||
}
|
||||
String webContentPath = webContentUrl.toExternalForm();
|
||||
context.setResourceBase(webContentPath);
|
||||
context.addServlet(new ServletHolder("frontend", DefaultServlet.class), "/");
|
||||
|
||||
// Configure specific websocket behavior
|
||||
JettyWebSocketServletContainerInitializer.configure(
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.schafkopf;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
|
||||
@@ -31,20 +30,11 @@ public class DedicatedServerConnection implements MessageSender {
|
||||
* Class that represents one Frontend Connection.
|
||||
*/
|
||||
public DedicatedServerConnection(String address, MessageListener messageListener) {
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(address);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
this.messageListener = messageListener;
|
||||
this.closeLatch = new CountDownLatch(1);
|
||||
this.connectionLatch = new CountDownLatch(1);
|
||||
|
||||
String host = uri.getHost();
|
||||
int port = uri.getPort();
|
||||
connect("ws://" + host + ":" + port);
|
||||
connect("ws://" + address);
|
||||
try {
|
||||
connectionLatch.await(); // Wait until the connection is established
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
Reference in New Issue
Block a user