untuning with escape...which should then remove from tunedids list and thus the source of truth whether or not to render the peer connector and rtc stuff
This commit is contained in:
@@ -86,7 +86,7 @@ export default function InitializeWs(io: any) {
|
||||
console.log(`${socket.id} now in rooms ${socket.rooms}`);
|
||||
|
||||
const clientUserIdsInRoom = [
|
||||
...io.sockets.adapter.rooms.get(roomName),
|
||||
...(io.sockets.adapter.rooms.get(roomName) ?? []),
|
||||
].map(
|
||||
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId]
|
||||
);
|
||||
@@ -102,6 +102,13 @@ export default function InitializeWs(io: any) {
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO: handle when user wants to completely leave a line (delete or removed from one)
|
||||
*/
|
||||
socket.on(ServerRequestChannels.DISCONNECT_FROM_LINE, () =>
|
||||
console.log("not implemented")
|
||||
);
|
||||
|
||||
/** TUNE | User tunes into the line either temporarily or toggled in */
|
||||
socket.on(
|
||||
ServerRequestChannels.TUNE_INTO_LINE,
|
||||
@@ -131,7 +138,7 @@ export default function InitializeWs(io: any) {
|
||||
}
|
||||
|
||||
const clientUserIdsInRoom = [
|
||||
...io.sockets.adapter.rooms.get(roomName),
|
||||
...(io.sockets.adapter.rooms.get(roomName) ?? []),
|
||||
].map(
|
||||
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId]
|
||||
);
|
||||
@@ -151,13 +158,6 @@ export default function InitializeWs(io: any) {
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO: handle when user wants to completely leave a line (delete or removed from one)
|
||||
*/
|
||||
socket.on(ServerRequestChannels.DISCONNECT_FROM_LINE, () =>
|
||||
console.log("not implemented")
|
||||
);
|
||||
|
||||
/**
|
||||
* Notify all connected users when someone UNTUNES from a room
|
||||
* ?might not be needed, all users' memory of tuned in users is irrelevant? don't need real time? but UI will show # of users tuned in?
|
||||
@@ -171,7 +171,7 @@ export default function InitializeWs(io: any) {
|
||||
console.log("someone left room");
|
||||
|
||||
const clientUserIdsInRoom = [
|
||||
...io.sockets.adapter.rooms.get(roomName),
|
||||
...(io.sockets.adapter.rooms.get(roomName) ?? []),
|
||||
].map(
|
||||
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId]
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
StartBroadcastingRequest,
|
||||
StopBroadcastingRequest,
|
||||
TuneToLineRequest,
|
||||
UntuneFromLineRequest,
|
||||
UserStartedBroadcastingResponse,
|
||||
UserStoppedBroadcastingResponse,
|
||||
} from "@nirvana/core/sockets/channels";
|
||||
@@ -257,6 +258,20 @@ function useSocketHandler(linesData: MasterLineData[]) {
|
||||
[$ws]
|
||||
);
|
||||
|
||||
const handleUnTuneToLine = useCallback(
|
||||
(lineId: string) => {
|
||||
// they already are in the socket room for updates including media connections and disconnections
|
||||
// but set the flag so that the line row can know whether or not to start the webrtc process
|
||||
// and know when to get out or disconnect from the webrtc when the flag turns off
|
||||
|
||||
$ws.emit(
|
||||
ServerRequestChannels.UNTUNE_FROM_LINE,
|
||||
new UntuneFromLineRequest(lineId)
|
||||
);
|
||||
},
|
||||
[$ws]
|
||||
);
|
||||
|
||||
/**
|
||||
* This is when the user wants to tell everyone that they are streaming/broadcasting/buzzing to
|
||||
* a specific line, whether they are toggle tuned or temporarily tuned in
|
||||
@@ -313,6 +328,7 @@ function useSocketHandler(linesData: MasterLineData[]) {
|
||||
handleStartBroadcast,
|
||||
handleStopBroadcast,
|
||||
handleFetchMoreAudioBlocks,
|
||||
handleUnTuneToLine,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ export default function NirvanaTerminal() {
|
||||
// simply using this query for specific data on loading
|
||||
// todo: add these properties in context provider value although more work down the line for control
|
||||
const { isLoading: isLoadingInitialLines } = useUserLines();
|
||||
const { linesMap, handleTuneToLine } = useLineDataProvider();
|
||||
const { linesMap, handleTuneToLine, handleUnTuneToLine } =
|
||||
useLineDataProvider();
|
||||
|
||||
useEffect(() => {
|
||||
console.log("change/update in lines map");
|
||||
@@ -56,8 +57,17 @@ export default function NirvanaTerminal() {
|
||||
const handleEscape = useCallback(() => {
|
||||
console.log("deselecting line");
|
||||
|
||||
setSelectedLineId(null);
|
||||
}, [setSelectedLineId]);
|
||||
setSelectedLineId((prevSelectedLineId) => {
|
||||
// ! only want to untune if it's a temporarily tuned line
|
||||
if (
|
||||
linesMap[prevSelectedLineId].currentUserMember?.state ===
|
||||
LineMemberState.INBOX
|
||||
)
|
||||
handleUnTuneToLine(prevSelectedLineId);
|
||||
|
||||
return null;
|
||||
});
|
||||
}, [setSelectedLineId, linesMap]);
|
||||
|
||||
const handleStartBroadcast = useCallback(
|
||||
(lineId: string) => () => {
|
||||
|
||||
Reference in New Issue
Block a user