aboutsummaryrefslogtreecommitdiff
path: root/src/features/waypoints/minewaypoints_socket.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/waypoints/minewaypoints_socket.js')
-rw-r--r--src/features/waypoints/minewaypoints_socket.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/features/waypoints/minewaypoints_socket.js b/src/features/waypoints/minewaypoints_socket.js
new file mode 100644
index 0000000..0cc31e5
--- /dev/null
+++ b/src/features/waypoints/minewaypoints_socket.js
@@ -0,0 +1,49 @@
+import socketData from "../../../soopyApis/socketData";
+import WebsiteCommunicator from "../../../soopyApis/websiteCommunicator";
+
+class MineWayPointsServer extends WebsiteCommunicator {
+ constructor() {
+ super(socketData.serverNameToId.minewaypoints);
+
+ this.setLocationHandler = undefined
+ this.hypixelServer = undefined
+ this.lastSend = Date.now()
+ }
+
+ onConnect() {
+ this.hypixelServer = undefined
+ }
+
+ onData(data) {
+ switch (data.type) {
+ case "setLocation":
+ if (this.setLocationHandler) {
+ this.setLocationHandler(data.area, data.location);
+ }
+ break;
+ }
+ }
+
+ setLocation(area, loc) {
+ this.sendData({
+ type: "setLocation",
+ area: area,
+ location: loc
+ });
+ }
+
+ setServer(server, worldTime) {
+ if (this.hypixelServer === server && Date.now() - this.lastSend < 10000) return;
+
+ this.lastSend = Date.now()
+ this.hypixelServer = server
+ this.sendData({
+ type: "setServer",
+ server: server,
+ time: worldTime
+ });
+ }
+}
+
+global.soopyV2mineWayPointsServer = new MineWayPointsServer()
+export default global.soopyV2mineWayPointsServer; \ No newline at end of file