mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
local websocket port requester
This commit is contained in:
parent
9a5415a199
commit
5f262cde16
@ -0,0 +1,26 @@
|
||||
package gearth.protocol.connection.proxy.unity;
|
||||
|
||||
import javafx.beans.InvalidationListener;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.JsrParamIdText;
|
||||
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
|
||||
// tells which port the packethandler is running on
|
||||
// server gets closed afterwards
|
||||
@ServerEndpoint(value = "/portrequest")
|
||||
public class PortRequester {
|
||||
|
||||
private final int packetHandlerPort;
|
||||
|
||||
public PortRequester(int port) {
|
||||
this.packetHandlerPort = port;
|
||||
}
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session) throws IOException {
|
||||
session.getBasicRemote().sendText("port " + packetHandlerPort);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package gearth.protocol.connection.proxy.unity;
|
||||
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
public class PortRequesterConfig extends ServerEndpointConfig.Configurator {
|
||||
|
||||
private final int packetHandlerPort;
|
||||
|
||||
public PortRequesterConfig(int packetHandlerPort) {
|
||||
this.packetHandlerPort = packetHandlerPort;
|
||||
}
|
||||
|
||||
public <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException {
|
||||
return (T)new PortRequester(packetHandlerPort);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user