Merge branch 'develop' of github.com:thecodingmachine/workadventure into develop

This commit is contained in:
_Bastler
2022-04-25 14:50:09 +02:00
67 changed files with 1638 additions and 643 deletions
+4 -17
View File
@@ -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.
*
+15 -9
View File
@@ -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);
-3
View File
@@ -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,
+2 -7
View File
@@ -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) {
+5 -8
View File
@@ -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,