aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2023-08-28 16:21:03 +0100
committerLuck <git@lucko.me>2023-08-28 16:21:03 +0100
commitfac7ec97a848835dacc860a596269be12ae86956 (patch)
tree0594925d3cd657b9154538ae3329e698bd1bd734 /spark-common/src
parent3c0c141189a0af706dfab9d052a2fd47d1906b39 (diff)
downloadspark-fac7ec97a848835dacc860a596269be12ae86956.tar.gz
spark-fac7ec97a848835dacc860a596269be12ae86956.tar.bz2
spark-fac7ec97a848835dacc860a596269be12ae86956.zip
Use a different websocket library
Diffstat (limited to 'spark-common/src')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java5
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/ws/ViewerSocketConnection.java9
3 files changed, 6 insertions, 12 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
index 84f435a..fc41b6f 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
@@ -22,9 +22,7 @@ package me.lucko.spark.common;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-
import me.lucko.bytesocks.client.BytesocksClient;
-import me.lucko.bytesocks.client.BytesocksClientFactory;
import me.lucko.spark.common.activitylog.ActivityLog;
import me.lucko.spark.common.api.SparkApi;
import me.lucko.spark.common.command.Arguments;
@@ -57,7 +55,6 @@ import me.lucko.spark.common.util.BytebinClient;
import me.lucko.spark.common.util.Configuration;
import me.lucko.spark.common.util.TemporaryFiles;
import me.lucko.spark.common.ws.TrustedKeyStore;
-
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
@@ -128,7 +125,7 @@ public class SparkPlatform {
String bytesocksHost = this.configuration.getString("bytesocksHost", "spark-usersockets.lucko.me");
this.bytebinClient = new BytebinClient(bytebinUrl, "spark-plugin");
- this.bytesocksClient = BytesocksClientFactory.newClient(bytesocksHost, "spark-plugin");
+ this.bytesocksClient = BytesocksClient.create(bytesocksHost, "spark-plugin");
this.trustedKeyStore = new TrustedKeyStore(this.configuration);
this.disableResponseBroadcast = this.configuration.getBoolean("disableResponseBroadcast", false);
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java
index 27e790f..ad0557d 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java
@@ -21,7 +21,6 @@
package me.lucko.spark.common.command.modules;
import com.google.common.collect.Iterables;
-
import me.lucko.bytesocks.client.BytesocksClient;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.activitylog.Activity;
@@ -46,7 +45,6 @@ import me.lucko.spark.common.util.MediaTypes;
import me.lucko.spark.common.util.MethodDisambiguator;
import me.lucko.spark.common.ws.ViewerSocket;
import me.lucko.spark.proto.SparkSamplerProtos;
-
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
@@ -339,7 +337,7 @@ public class SamplerModule implements CommandModule {
private void profilerOpen(SparkPlatform platform, CommandSender sender, CommandResponseHandler resp, Arguments arguments) {
BytesocksClient bytesocksClient = platform.getBytesocksClient();
if (bytesocksClient == null) {
- resp.replyPrefixed(text("The live viewer is only supported on Java 11 or newer.", RED));
+ resp.replyPrefixed(text("The live viewer is not supported.", RED));
return;
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/ws/ViewerSocketConnection.java b/spark-common/src/main/java/me/lucko/spark/common/ws/ViewerSocketConnection.java
index 9079860..2173f53 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/ws/ViewerSocketConnection.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/ws/ViewerSocketConnection.java
@@ -21,7 +21,6 @@
package me.lucko.spark.common.ws;
import com.google.protobuf.ByteString;
-
import me.lucko.bytesocks.client.BytesocksClient;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.proto.SparkWebSocketProtos.PacketWrapper;
@@ -87,7 +86,7 @@ public class ViewerSocketConnection implements BytesocksClient.Listener, AutoClo
* @return the channel id
*/
public String getChannelId() {
- return this.socket.getChannelId();
+ return this.socket.channelId();
}
/**
@@ -100,7 +99,7 @@ public class ViewerSocketConnection implements BytesocksClient.Listener, AutoClo
}
@Override
- public void onText(CharSequence data) {
+ public void onText(String data) {
try {
RawPacket packet = decodeRawPacket(data);
handleRawPacket(packet);
@@ -178,8 +177,8 @@ public class ViewerSocketConnection implements BytesocksClient.Listener, AutoClo
* @param data the encoded data
* @return the decoded packet
*/
- private RawPacket decodeRawPacket(CharSequence data) throws IOException {
- byte[] buf = Base64.getDecoder().decode(data.toString());
+ private RawPacket decodeRawPacket(String data) throws IOException {
+ byte[] buf = Base64.getDecoder().decode(data);
return RawPacket.parseFrom(buf);
}