improve
This commit is contained in:
parent
d6b20082ea
commit
094aeb061c
|
@ -17,7 +17,7 @@ export class Client {
|
||||||
.join("");
|
.join("");
|
||||||
this.uniqWsID = crypto.randomUUID();
|
this.uniqWsID = crypto.randomUUID();
|
||||||
}
|
}
|
||||||
updateRole() {
|
sendWelcome() {
|
||||||
const profile = Server.profiles.get(this.id)
|
const profile = Server.profiles.get(this.id)
|
||||||
if(!profile) return;
|
if(!profile) return;
|
||||||
this.send(new proto.ServerMessage({
|
this.send(new proto.ServerMessage({
|
||||||
|
|
16
src/Room.ts
16
src/Room.ts
|
@ -86,20 +86,8 @@ export class Room {
|
||||||
particpiant.addClient(ws.data);
|
particpiant.addClient(ws.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const welcome = new proto.ServerMessage({
|
ws.data.sendWelcome();
|
||||||
event: proto.ServerMessage_EventType.WELCOME,
|
|
||||||
welcome: {
|
|
||||||
id: ws.data.id,
|
|
||||||
name: particpiant.profile.name,
|
|
||||||
color: particpiant.profile.color,
|
|
||||||
room: this.name,
|
|
||||||
owner: this.owner,
|
|
||||||
chat: this.chats,
|
|
||||||
role: particpiant.profile.role,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
ws.data.send(welcome);
|
|
||||||
if (particpiant.clients.length <= 1) {
|
if (particpiant.clients.length <= 1) {
|
||||||
//#region Annouce to everyone that the user has joined
|
//#region Annouce to everyone that the user has joined
|
||||||
const joinMessage = new proto.ServerMessage({
|
const joinMessage = new proto.ServerMessage({
|
||||||
|
|
|
@ -119,7 +119,7 @@ export class Server {
|
||||||
profile.emit("update");
|
profile.emit("update");
|
||||||
Server.wses.forEach((z) => {
|
Server.wses.forEach((z) => {
|
||||||
if (z.data.id == profile.id) {
|
if (z.data.id == profile.id) {
|
||||||
z?.data?.updateRole();
|
z?.data?.sendWelcome();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -156,7 +156,7 @@ export class Server {
|
||||||
profile.emit("update");
|
profile.emit("update");
|
||||||
Server.wses.forEach((z) => {
|
Server.wses.forEach((z) => {
|
||||||
if (z.data.id == profile.id) {
|
if (z.data.id == profile.id) {
|
||||||
z?.data?.updateRole();
|
z?.data?.sendWelcome();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ws.data.send(
|
ws.data.send(
|
||||||
|
@ -176,7 +176,7 @@ export class Server {
|
||||||
profile.emit("update");
|
profile.emit("update");
|
||||||
Server.wses.forEach((z) => {
|
Server.wses.forEach((z) => {
|
||||||
if (z.data.id == profile.id) {
|
if (z.data.id == profile.id) {
|
||||||
z?.data?.updateRole();
|
z?.data?.sendWelcome();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue