do not send users from other pages under any circumstances
This commit is contained in:
parent
91ab64a491
commit
6b9b67eb3f
3 changed files with 23 additions and 5 deletions
|
@ -166,7 +166,7 @@ if (!window.TE_ACTIVE) {
|
|||
pingDiv.style.top = `${y}px`;
|
||||
pingDiv.style.left = `${x}px`;
|
||||
otherCursors.appendChild(pingDiv);
|
||||
setTimeout(() => pingDiv.remove(), 1999);
|
||||
setTimeout(() => pingDiv.remove(), 2000);
|
||||
}
|
||||
|
||||
function removeClient(id) {
|
||||
|
|
14
client/otherpagetest.html
Normal file
14
client/otherpagetest.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>UserScript test page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test page :)</h1>
|
||||
|
||||
<script src="./Terminal-00-Multiuser.user.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -59,13 +59,17 @@ server.on("connection", (socket) => {
|
|||
page = "";
|
||||
}
|
||||
let lengthOfUsernames = 0;
|
||||
const usersOnPage = new Array<User>();
|
||||
await users.forEach(otherUser => {
|
||||
if (otherUser.currentURL === page) {
|
||||
usersOnPage.push(otherUser);
|
||||
lengthOfUsernames += otherUser.username.length + 1; // + 1 for length byte
|
||||
}
|
||||
});
|
||||
const usersToSend = createWriter(Endian.LE, 3 + (users.length * 12) + lengthOfUsernames).writeByte(MessageType.Clients).writeUShort(users.length);
|
||||
await users.forEach(otherUser => {
|
||||
const usersToSend = createWriter(Endian.LE, 3 + (usersOnPage.length * 12) + lengthOfUsernames).writeByte(MessageType.Clients).writeUShort(usersOnPage.length);
|
||||
for (const otherUser of usersOnPage) {
|
||||
usersToSend.writeUInt(otherUser.id).writeShortString(otherUser.username).writeFloat(otherUser.cursorX).writeInt(otherUser.cursorY);
|
||||
});
|
||||
}
|
||||
user = users.set(myUUID, new User(socket, username, page));
|
||||
sendToAllButSelf(user, createWriter(Endian.LE, 6 + username.length).writeByte(MessageType.ClientJoined).writeUInt(user.id).writeShortString(username).toBuffer());
|
||||
user.send(usersToSend.toBuffer());
|
||||
|
|
Loading…
Reference in a new issue