mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-20 17:11:20 -08:00
New formatting rules
This commit is contained in:
1 parent
7ac7f7d424
commit
ad3b697517
117 files changed
+16689
-16681
No files matched your search
@@ -6,7 +6,6 @@ import dev.slimevr.protocol.ProtocolAPI;
|
||||
import dev.slimevr.protocol.ProtocolAPIServer;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.drafts.Draft;
|
||||
import org.java_websocket.drafts.Draft_6455;
|
||||
import org.java_websocket.handshake.ClientHandshake;
|
||||
import org.java_websocket.server.WebSocketServer;
|
||||
@@ -19,55 +18,55 @@ import java.util.Map;
|
||||
|
||||
public class WebsocketAPI extends WebSocketServer implements ProtocolAPIServer {
|
||||
|
||||
public final VRServer server;
|
||||
public final ProtocolAPI protocolAPI;
|
||||
private final Map<Integer, GenericConnection> websocketConnections = new HashMap<>();
|
||||
public final VRServer server;
|
||||
public final ProtocolAPI protocolAPI;
|
||||
private final Map<Integer, GenericConnection> websocketConnections = new HashMap<>();
|
||||
|
||||
public WebsocketAPI(VRServer server, ProtocolAPI protocolAPI) {
|
||||
super(new InetSocketAddress(21110), Collections.singletonList(new Draft_6455()));
|
||||
this.server = server;
|
||||
this.protocolAPI = protocolAPI;
|
||||
public WebsocketAPI(VRServer server, ProtocolAPI protocolAPI) {
|
||||
super(new InetSocketAddress(21110), Collections.singletonList(new Draft_6455()));
|
||||
this.server = server;
|
||||
this.protocolAPI = protocolAPI;
|
||||
|
||||
this.protocolAPI.registerAPIServer(this);
|
||||
}
|
||||
this.protocolAPI.registerAPIServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||
LogManager.log.info("[WebSocketAPI] New connection from: " + conn.getRemoteSocketAddress().getAddress().getHostAddress());
|
||||
@Override
|
||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||
LogManager.log.info("[WebSocketAPI] New connection from: " + conn.getRemoteSocketAddress().getAddress().getHostAddress());
|
||||
|
||||
this.websocketConnections.put(conn.hashCode(), new WebsocketConnection(conn));
|
||||
}
|
||||
this.websocketConnections.put(conn.hashCode(), new WebsocketConnection(conn));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||
LogManager.log.info("[WebSocketAPI] Disconnected: " + conn.getRemoteSocketAddress().getAddress().getHostAddress() + ", (" + code + ") " + reason + ". Remote: " + remote);
|
||||
this.websocketConnections.remove(conn.hashCode());
|
||||
}
|
||||
@Override
|
||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||
LogManager.log.info("[WebSocketAPI] Disconnected: " + conn.getRemoteSocketAddress().getAddress().getHostAddress() + ", (" + code + ") " + reason + ". Remote: " + remote);
|
||||
this.websocketConnections.remove(conn.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket conn, String message) {
|
||||
}
|
||||
@Override
|
||||
public void onMessage(WebSocket conn, String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket conn, ByteBuffer message) {
|
||||
GenericConnection connection = this.websocketConnections.get(conn.hashCode());
|
||||
if (connection != null)
|
||||
this.protocolAPI.onMessage(connection, message);
|
||||
}
|
||||
@Override
|
||||
public void onMessage(WebSocket conn, ByteBuffer message) {
|
||||
GenericConnection connection = this.websocketConnections.get(conn.hashCode());
|
||||
if (connection != null)
|
||||
this.protocolAPI.onMessage(connection, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(WebSocket conn, Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@Override
|
||||
public void onError(WebSocket conn, Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
LogManager.log.info("[WebSocketAPI] Web Socket API started on port " + getPort());
|
||||
setConnectionLostTimeout(0);
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
LogManager.log.info("[WebSocketAPI] Web Socket API started on port " + getPort());
|
||||
setConnectionLostTimeout(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, GenericConnection> getAPIConnections() {
|
||||
return this.websocketConnections;
|
||||
}
|
||||
@Override
|
||||
public Map<Integer, GenericConnection> getAPIConnections() {
|
||||
return this.websocketConnections;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user