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