diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 5b1e13bf..f0c6e627 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -144,9 +144,8 @@ export class GameRoom { joinRoomMessage.getUseruuid(), joinRoomMessage.getIpaddress(), position, - false, this.positionNotifier, - joinRoomMessage.getAway(), + joinRoomMessage.getStatus(), socket, joinRoomMessage.getTagList(), joinRoomMessage.getVisitcardurl(), @@ -208,6 +207,9 @@ export class GameRoom { updatePlayerDetails(user: User, playerDetailsMessage: SetPlayerDetailsMessage) { user.updateDetails(playerDetailsMessage); + if (user.group !== undefined && user.silent) { + this.leaveGroup(user); + } } private updateUserGroup(user: User): void { @@ -345,21 +347,6 @@ export class GameRoom { }); } - setSilent(user: User, silent: boolean) { - if (user.silent === silent) { - return; - } - - user.silent = silent; - if (silent && user.group !== undefined) { - this.leaveGroup(user); - } - if (!silent) { - // If we are back to life, let's trigger a position update to see if we can join some group. - this.updatePosition(user, user.getPosition()); - } - } - /** * Makes a user leave a group and closes and destroy the group if the group contains only one remaining person. * diff --git a/back/src/Model/User.ts b/back/src/Model/User.ts index 7a6a53f1..b103f240 100644 --- a/back/src/Model/User.ts +++ b/back/src/Model/User.ts @@ -5,6 +5,7 @@ import { Movable } from "../Model/Movable"; import { PositionNotifier } from "../Model/PositionNotifier"; import { ServerDuplexStream } from "grpc"; import { + AvailabilityStatus, BatchMessage, CompanionMessage, FollowAbortMessage, @@ -30,9 +31,8 @@ export class User implements Movable { public readonly uuid: string, public readonly IPAddress: string, private position: PointInterface, - public silent: boolean, private positionNotifier: PositionNotifier, - private away: boolean, + private status: AvailabilityStatus, public readonly socket: UserSocket, public readonly tags: string[], public readonly visitCardUrl: string | null, @@ -90,8 +90,12 @@ export class User implements Movable { return this.outlineColor; } - public isAway(): boolean { - return this.away; + public getStatus(): AvailabilityStatus { + return this.status; + } + + public get silent(): boolean { + return this.status === AvailabilityStatus.SILENT || this.status === AvailabilityStatus.JITSI; } get following(): User | undefined { @@ -134,9 +138,11 @@ export class User implements Movable { } this.voiceIndicatorShown = details.getShowvoiceindicator()?.getValue(); - const away = details.getAway(); - if (away) { - this.away = away.getValue(); + const status = details.getStatus(); + let sendStatusUpdate = false; + if (status && status !== this.status) { + this.status = status; + sendStatusUpdate = true; } const playerDetails = new SetPlayerDetailsMessage(); @@ -147,8 +153,8 @@ export class User implements Movable { if (this.voiceIndicatorShown !== undefined) { playerDetails.setShowvoiceindicator(new BoolValue().setValue(this.voiceIndicatorShown)); } - if (details.getAway() !== undefined) { - playerDetails.setAway(new BoolValue().setValue(this.away)); + if (sendStatusUpdate) { + playerDetails.setStatus(details.getStatus()); } this.positionNotifier.updatePlayerDetails(this, playerDetails); diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index c07d7e76..7211facb 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -22,7 +22,6 @@ import { SendUserMessage, ServerToAdminClientMessage, SetPlayerDetailsMessage, - SilentMessage, UserMovesMessage, VariableMessage, WebRtcSignalToServerMessage, @@ -80,8 +79,6 @@ const roomManager: IRoomManagerServer = { user, message.getUsermovesmessage() as UserMovesMessage ); - } else if (message.hasSilentmessage()) { - socketManager.handleSilentMessage(room, user, message.getSilentmessage() as SilentMessage); } else if (message.hasItemeventmessage()) { socketManager.handleItemEvent( room, diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index c186658f..8d71f4d8 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -5,7 +5,6 @@ import { PointMessage, RoomJoinedMessage, ServerToClientMessage, - SilentMessage, SubMessage, UserMovedMessage, UserMovesMessage, @@ -160,10 +159,6 @@ export class SocketManager { room.updatePlayerDetails(user, playerDetailsMessage); } - handleSilentMessage(room: GameRoom, user: User, silentMessage: SilentMessage) { - room.setSilent(user, silentMessage.getSilent()); - } - handleItemEvent(room: GameRoom, user: User, itemEventMessage: ItemEventMessage) { const itemEvent = ProtobufUtils.toItemEvent(itemEventMessage); @@ -328,7 +323,7 @@ export class SocketManager { userJoinedZoneMessage.setUserid(thing.id); userJoinedZoneMessage.setUseruuid(thing.uuid); userJoinedZoneMessage.setName(thing.name); - userJoinedZoneMessage.setAway(thing.isAway()); + userJoinedZoneMessage.setStatus(thing.getStatus()); userJoinedZoneMessage.setCharacterlayersList(ProtobufUtils.toCharacterLayerMessages(thing.characterLayers)); userJoinedZoneMessage.setPosition(ProtobufUtils.toPositionMessage(thing.getPosition())); userJoinedZoneMessage.setFromzone(this.toProtoZone(fromZone)); @@ -656,7 +651,7 @@ export class SocketManager { userJoinedMessage.setUserid(thing.id); userJoinedMessage.setUseruuid(thing.uuid); userJoinedMessage.setName(thing.name); - userJoinedMessage.setAway(thing.isAway()); + userJoinedMessage.setStatus(thing.getStatus()); userJoinedMessage.setCharacterlayersList(ProtobufUtils.toCharacterLayerMessages(thing.characterLayers)); userJoinedMessage.setPosition(ProtobufUtils.toPositionMessage(thing.getPosition())); if (thing.visitCardUrl) { diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index a5af48f8..70e4c0a0 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -6,6 +6,7 @@ import { Zone } from "../src/Model/Zone"; import { Movable } from "../src/Model/Movable"; import { PositionInterface } from "../src/Model/PositionInterface"; import { ZoneSocket } from "../src/RoomManager"; +import { AvailabilityStatus } from "../src/Messages/generated/messages_pb"; describe("PositionNotifier", () => { it("should receive notifications when player moves", () => { @@ -40,9 +41,8 @@ describe("PositionNotifier", () => { moving: false, direction: "down", }, - false, positionNotifier, - false, + AvailabilityStatus.ONLINE, {} as UserSocket, [], null, @@ -60,9 +60,8 @@ describe("PositionNotifier", () => { moving: false, direction: "down", }, - false, positionNotifier, - false, + AvailabilityStatus.ONLINE, {} as UserSocket, [], null, @@ -150,9 +149,8 @@ describe("PositionNotifier", () => { moving: false, direction: "down", }, - false, positionNotifier, - false, + AvailabilityStatus.ONLINE, {} as UserSocket, [], null, @@ -170,9 +168,8 @@ describe("PositionNotifier", () => { moving: false, direction: "down", }, - false, positionNotifier, - false, + AvailabilityStatus.ONLINE, {} as UserSocket, [], null, diff --git a/front/public/resources/icons/icon_status_indicator_inside.png b/front/public/resources/icons/icon_status_indicator_inside.png new file mode 100644 index 00000000..29a2daad Binary files /dev/null and b/front/public/resources/icons/icon_status_indicator_inside.png differ diff --git a/front/public/resources/icons/icon_status_indicator_outline.png b/front/public/resources/icons/icon_status_indicator_outline.png new file mode 100644 index 00000000..67f86ec5 Binary files /dev/null and b/front/public/resources/icons/icon_status_indicator_outline.png differ diff --git a/front/src/Api/desktop/index.ts b/front/src/Api/desktop/index.ts index 0b1ea9f9..6e38403c 100644 --- a/front/src/Api/desktop/index.ts +++ b/front/src/Api/desktop/index.ts @@ -1,4 +1,4 @@ -import { isSilentStore, requestedCameraState, requestedMicrophoneState } from "../../Stores/MediaStore"; +import { requestedCameraState, requestedMicrophoneState, silentStore } from "../../Stores/MediaStore"; import { get } from "svelte/store"; import { WorkAdventureDesktopApi } from "@wa-preload-app"; @@ -36,8 +36,8 @@ class DesktopApi { } }); - isSilentStore.subscribe((value) => { - this.isSilent = value; + silentStore.subscribe((silent) => { + this.isSilent = silent; }); } } diff --git a/front/src/Components/CameraControls.svelte b/front/src/Components/CameraControls.svelte index b9cb7801..fad3c3c1 100644 --- a/front/src/Components/CameraControls.svelte +++ b/front/src/Components/CameraControls.svelte @@ -1,6 +1,6 @@
@@ -94,7 +87,7 @@
@@ -103,7 +96,7 @@
@@ -113,26 +106,26 @@
- {#if $requestedScreenSharingState && !isSilent} + {#if $requestedScreenSharingState && !$silentStore} Start screen sharing {:else} Stop screen sharing {/if}
-
- {#if $requestedCameraState && !isSilent} +
+ {#if $requestedCameraState && !$silentStore} Turn on webcam {:else} Turn off webcam {/if}
-
- {#if $requestedMicrophoneState && !isSilent} +
+ {#if $requestedMicrophoneState && !$silentStore} Turn on microphone {:else} Turn off microphone diff --git a/front/src/Components/MyCamera.svelte b/front/src/Components/MyCamera.svelte index 7f97ff22..d72a8eee 100644 --- a/front/src/Components/MyCamera.svelte +++ b/front/src/Components/MyCamera.svelte @@ -1,6 +1,6 @@
- {#if isSilent} + {#if $silentStore}
{$LL.camera.my.silentZone()}
{:else if $localStreamStore.type === "success" && $localStreamStore.stream}