mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
38 lines
762 B
Java
38 lines
762 B
Java
package dev.slimevr.websocketapi;
|
|
|
|
import dev.slimevr.protocol.ConnectionContext;
|
|
import dev.slimevr.protocol.GenericConnection;
|
|
import org.java_websocket.WebSocket;
|
|
|
|
import java.nio.ByteBuffer;
|
|
import java.util.UUID;
|
|
|
|
public class WebsocketConnection implements GenericConnection {
|
|
|
|
public final ConnectionContext context;
|
|
public final WebSocket conn;
|
|
public UUID id;
|
|
|
|
public WebsocketConnection(WebSocket conn) {
|
|
this.context = new ConnectionContext();
|
|
this.conn = conn;
|
|
this.id = UUID.randomUUID();
|
|
}
|
|
|
|
@Override
|
|
public ConnectionContext getContext() {
|
|
return this.context;
|
|
}
|
|
|
|
@Override
|
|
public void send(ByteBuffer bytes) {
|
|
if (this.conn.isOpen())
|
|
this.conn.send(bytes);
|
|
}
|
|
|
|
@Override
|
|
public UUID getConnectionId() {
|
|
return id;
|
|
}
|
|
}
|