Fixes for suprious group messages
This commit is contained in:
parent
1d3e17241a
commit
cd170dc471
3 changed files with 33 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name MultiProbe
|
// @name MultiProbe
|
||||||
// @namespace https://*.angusnicneven.com/*
|
// @namespace https://*.angusnicneven.com/*
|
||||||
// @version 20240502.3
|
// @version 20240506.1
|
||||||
// @description Probe with friends!
|
// @description Probe with friends!
|
||||||
// @author tgpholly
|
// @author tgpholly
|
||||||
// @match https://*.angusnicneven.com/*
|
// @match https://*.angusnicneven.com/*
|
||||||
|
@ -32,11 +32,13 @@ if (!window.TE_ACTIVE) {
|
||||||
setInterval(nukeCC, 1000);
|
setInterval(nukeCC, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.multiprobe_debug = false;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Make sure to change the userscript version too!!!!!!!!!!
|
// Make sure to change the userscript version too!!!!!!!!!!
|
||||||
const USERSCRIPT_VERSION_RAW = "20240502.3";
|
const USERSCRIPT_VERSION_RAW = "20240506.1";
|
||||||
const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", ""));
|
const USERSCRIPT_VERSION = parseInt(USERSCRIPT_VERSION_RAW.replace(".", ""));
|
||||||
|
|
||||||
if (!continueRunningScript) {
|
if (!continueRunningScript) {
|
||||||
|
@ -400,6 +402,11 @@ kbd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function log(type, text) {
|
||||||
|
const d = new Date();
|
||||||
|
console.log(`[hNET] [${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}:${String(d.getSeconds()).padStart(2, "0")}.${String(d.getMilliseconds()).padStart(4, "0")}] [${type}] ${text}`);
|
||||||
|
}
|
||||||
|
|
||||||
let allowedPings = 10;
|
let allowedPings = 10;
|
||||||
window.onkeypress = (e) => {
|
window.onkeypress = (e) => {
|
||||||
if (e.key === "p") {
|
if (e.key === "p") {
|
||||||
|
@ -494,6 +501,9 @@ kbd {
|
||||||
const clientY = reader.readInt();
|
const clientY = reader.readInt();
|
||||||
remoteClients.set(clientId, new RemoteClient(clientName)).rawSetPosInit(clientX, clientY);
|
remoteClients.set(clientId, new RemoteClient(clientName)).rawSetPosInit(clientX, clientY);
|
||||||
}
|
}
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `Initial client packet, got ${clientCount} clients.`);
|
||||||
|
}
|
||||||
ready = true;
|
ready = true;
|
||||||
if (windowContainer) {
|
if (windowContainer) {
|
||||||
windowContainer.remove();
|
windowContainer.remove();
|
||||||
|
@ -509,6 +519,9 @@ kbd {
|
||||||
const clientId = reader.readUInt();
|
const clientId = reader.readUInt();
|
||||||
const clientName = reader.readShortString();
|
const clientName = reader.readShortString();
|
||||||
remoteClients.set(clientId, new RemoteClient(clientName));
|
remoteClients.set(clientId, new RemoteClient(clientName));
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `New client joined page: ${clientName} ID=${clientId}`);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageType.CursorPos:
|
case MessageType.CursorPos:
|
||||||
|
@ -518,6 +531,9 @@ kbd {
|
||||||
const cursorX = reader.readFloat();
|
const cursorX = reader.readFloat();
|
||||||
const cursorY = reader.readInt();
|
const cursorY = reader.readInt();
|
||||||
remoteClients.get(clientId).rawSetPos(cursorX, cursorY);
|
remoteClients.get(clientId).rawSetPos(cursorX, cursorY);
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `Cursor position update for ${clientId}, X=${cursorX}, Y=${cursorY}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -525,6 +541,9 @@ kbd {
|
||||||
{
|
{
|
||||||
const clientId = reader.readUInt();
|
const clientId = reader.readUInt();
|
||||||
removeClient(clientId);
|
removeClient(clientId);
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `Client ${clientId} left or switched pages`);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageType.Ping:
|
case MessageType.Ping:
|
||||||
|
@ -532,6 +551,9 @@ kbd {
|
||||||
const cursorX = reader.readFloat();
|
const cursorX = reader.readFloat();
|
||||||
const cursorY = reader.readInt();
|
const cursorY = reader.readInt();
|
||||||
createPing(cursorX * clientWidth, cursorY);
|
createPing(cursorX * clientWidth, cursorY);
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `Got a ping, X=${cursorX}, Y=${cursorY}`);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageType.GroupData:
|
case MessageType.GroupData:
|
||||||
|
@ -540,9 +562,15 @@ kbd {
|
||||||
groupUsers.innerHTML = "";
|
groupUsers.innerHTML = "";
|
||||||
groupTitle.innerText = reader.readShortString();
|
groupTitle.innerText = reader.readShortString();
|
||||||
const groupUserCount = reader.readUShort();
|
const groupUserCount = reader.readUShort();
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `Server sent group information for "${groupTitle.innerText}" (${groupUserCount} clients)`);
|
||||||
|
}
|
||||||
for (let i = 0; i < groupUserCount; i++) {
|
for (let i = 0; i < groupUserCount; i++) {
|
||||||
const groupUsername = reader.readShortString();
|
const groupUsername = reader.readShortString();
|
||||||
const groupUserLocation = reader.readString();
|
const groupUserLocation = reader.readString();
|
||||||
|
if (window.multiprobe_debug) {
|
||||||
|
log("RECV", `[GROUP USER] USERNAME=${groupUsername}, LOCATION=${groupUserLocation}`);
|
||||||
|
}
|
||||||
createGroupUser(groupUsername, groupUserLocation);
|
createGroupUser(groupUsername, groupUserLocation);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -374,7 +374,7 @@ websocketServer.on("connection", (socket) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendGroupUpdate(sendUser:RemoteUser, groupSend = false) {
|
async function sendGroupUpdate(sendUser:RemoteUser, groupSend = false) {
|
||||||
if (!sendUser || user.groupId === Number.MIN_VALUE) {
|
if (!sendUser || sendUser.groupId === Number.MIN_VALUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default class RemoteUser {
|
||||||
public allowedPings:number;
|
public allowedPings:number;
|
||||||
public lastPingReset:number;
|
public lastPingReset:number;
|
||||||
public userId:number;
|
public userId:number;
|
||||||
public groupId:number;
|
public groupId:number = Number.MIN_VALUE;
|
||||||
public groupName:string;
|
public groupName:string;
|
||||||
|
|
||||||
constructor(socket:WebSocket, username:string, currentURL:string, rawURL:string, userId:number, groupId:number, groupName:string) {
|
constructor(socket:WebSocket, username:string, currentURL:string, rawURL:string, userId:number, groupId:number, groupName:string) {
|
||||||
|
|
Loading…
Reference in a new issue