feat: add new socket message when user joins room
This commit is contained in:
parent
28b0095c8a
commit
bef0f3e51d
@ -698,6 +698,21 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "USER_JOINED": {
|
||||||
|
const { username, userId, socketId } = decryptedData.payload;
|
||||||
|
const collaborators = upsertMap(
|
||||||
|
userId,
|
||||||
|
{
|
||||||
|
username,
|
||||||
|
userId,
|
||||||
|
socketId,
|
||||||
|
},
|
||||||
|
this.collaborators,
|
||||||
|
);
|
||||||
|
this.excalidrawAPI.updateScene({
|
||||||
|
collaborators: new Map(collaborators),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -766,6 +781,15 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
} else {
|
} else {
|
||||||
this.portal.socketInitialized = true;
|
this.portal.socketInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.portal.socket) {
|
||||||
|
this.portal.brodcastUserJoinedRoom({
|
||||||
|
username: this.state.username,
|
||||||
|
userId: this.state.userId,
|
||||||
|
socketId: this.portal.socket.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -229,6 +229,23 @@ class Portal {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
brodcastUserJoinedRoom = (payload: {
|
||||||
|
username: string;
|
||||||
|
userId: string;
|
||||||
|
socketId: string;
|
||||||
|
}) => {
|
||||||
|
if (this.socket) {
|
||||||
|
const data: SocketUpdateDataSource["USER_JOINED"] = {
|
||||||
|
type: "USER_JOINED",
|
||||||
|
payload,
|
||||||
|
};
|
||||||
|
return this._broadcastSocketData(
|
||||||
|
data as SocketUpdateData,
|
||||||
|
false, // volatile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Portal;
|
export default Portal;
|
||||||
|
@ -123,6 +123,14 @@ export type SocketUpdateDataSource = {
|
|||||||
socketId: string;
|
socketId: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
USER_JOINED: {
|
||||||
|
type: "USER_JOINED";
|
||||||
|
payload: {
|
||||||
|
username: string;
|
||||||
|
userId: string;
|
||||||
|
socketId: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SocketUpdateDataIncoming =
|
export type SocketUpdateDataIncoming =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user