forked from lamp/chat
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
3c6a549a5f |
@ -25,6 +25,7 @@ io.on("connection", socket => {
|
||||
})
|
||||
socket.on("user", user => {
|
||||
if (!socket.quotas.user.spend()) return;
|
||||
if (typeof user != "object") return;
|
||||
user = {
|
||||
name: user.name?.toString().trim().substring(0,32),
|
||||
color: user.color?.toString().trim().substring(0,32),
|
||||
@ -40,6 +41,7 @@ io.on("connection", socket => {
|
||||
broadcastUsers();
|
||||
});
|
||||
socket.once("user", async user => {
|
||||
if (typeof user != "object") return;
|
||||
//await newMessage({color: "#00FF00", content:`${user.name} connected`});
|
||||
socket.on("disconnect", () => {
|
||||
//newMessage({color: "#FF0000", content: `${socket.data.user.name} disconnected`});
|
||||
@ -47,6 +49,7 @@ io.on("connection", socket => {
|
||||
});
|
||||
socket.on("message", message => {
|
||||
if (!socket.quotas.message.spend()) return;
|
||||
if (typeof message != "object") return;
|
||||
newMessage({
|
||||
content: message.content?.toString().substring(0,10000),
|
||||
user: {...socket.data.user}
|
||||
@ -58,6 +61,7 @@ io.on("connection", socket => {
|
||||
io.emit("type", socket.id);
|
||||
});
|
||||
socket.on("mouse", (x, y) => {
|
||||
if (typeof x != "number" || typeof y != "number") return;
|
||||
//socket.broadcast.emit("mouse", x, y, socket.id);
|
||||
// see own cursor (test)
|
||||
io.emit("mouse", x, y, socket.id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user