Merge pull request #1144 from thecodingmachine/betterVisitCard
FIX: improved the visit card, cleanup the code
This commit is contained in:
commit
bcc86d6041
@ -1,9 +1,6 @@
|
||||
import {
|
||||
BatchMessage,
|
||||
PusherToBackMessage,
|
||||
ServerToAdminClientMessage,
|
||||
ServerToClientMessage,
|
||||
SubMessage, UserJoinedRoomMessage, UserLeftRoomMessage
|
||||
UserJoinedRoomMessage, UserLeftRoomMessage
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import {AdminSocket} from "../RoomManager";
|
||||
|
||||
|
@ -108,6 +108,7 @@ export class GameRoom {
|
||||
this.positionNotifier,
|
||||
socket,
|
||||
joinRoomMessage.getTagList(),
|
||||
joinRoomMessage.getVisitcardurl(),
|
||||
joinRoomMessage.getName(),
|
||||
ProtobufUtils.toCharacterLayerObjects(joinRoomMessage.getCharacterlayerList()),
|
||||
joinRoomMessage.getCompanion()
|
||||
|
@ -22,6 +22,7 @@ export class User implements Movable {
|
||||
private positionNotifier: PositionNotifier,
|
||||
public readonly socket: UserSocket,
|
||||
public readonly tags: string[],
|
||||
public readonly visitCardUrl: string|null,
|
||||
public readonly name: string,
|
||||
public readonly characterLayers: CharacterLayer[],
|
||||
public readonly companion?: CompanionMessage
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
JoinRoomMessage,
|
||||
PlayGlobalMessage,
|
||||
PusherToBackMessage,
|
||||
QueryJitsiJwtMessage, RefreshRoomPromptMessage, RequestVisitCardMessage,
|
||||
QueryJitsiJwtMessage, RefreshRoomPromptMessage,
|
||||
ServerToAdminClientMessage,
|
||||
ServerToClientMessage,
|
||||
SilentMessage,
|
||||
@ -74,8 +74,6 @@ const roomManager: IRoomManagerServer = {
|
||||
socketManager.handleQueryJitsiJwtMessage(user, message.getQueryjitsijwtmessage() as QueryJitsiJwtMessage);
|
||||
} else if (message.hasEmotepromptmessage()){
|
||||
socketManager.handleEmoteEventMessage(room, user, message.getEmotepromptmessage() as EmotePromptMessage);
|
||||
} else if (message.hasRequestvisitcardmessage()) {
|
||||
socketManager.handleRequestVisitCardMessage(room, user, message.getRequestvisitcardmessage() as RequestVisitCardMessage);
|
||||
}else if (message.hasSendusermessage()) {
|
||||
const sendUserMessage = message.getSendusermessage();
|
||||
if(sendUserMessage !== undefined) {
|
||||
|
@ -1,22 +0,0 @@
|
||||
import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable";
|
||||
import Axios from "axios";
|
||||
|
||||
|
||||
class AdminApi {
|
||||
|
||||
fetchVisitCardUrl(membershipUuid: string): Promise<string> {
|
||||
if (ADMIN_API_URL) {
|
||||
return Axios.get(ADMIN_API_URL + '/api/membership/'+membershipUuid,
|
||||
{headers: {"Authorization": `${ADMIN_API_TOKEN}`}}
|
||||
).then((res) => {
|
||||
return res.data;
|
||||
}).catch(() => {
|
||||
return 'INVALID';
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve('INVALID')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const adminApi = new AdminApi();
|
@ -27,7 +27,7 @@ import {
|
||||
WorldFullWarningMessage,
|
||||
UserLeftZoneMessage,
|
||||
EmoteEventMessage,
|
||||
BanUserMessage, RefreshRoomMessage, EmotePromptMessage, RequestVisitCardMessage, VisitCardMessage,
|
||||
BanUserMessage, RefreshRoomMessage, EmotePromptMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import {User, UserSocket} from "../Model/User";
|
||||
import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils";
|
||||
@ -51,7 +51,6 @@ import {Zone} from "_Model/Zone";
|
||||
import Debug from "debug";
|
||||
import {Admin} from "_Model/Admin";
|
||||
import crypto from "crypto";
|
||||
import {adminApi} from "./AdminApi";
|
||||
|
||||
|
||||
const debug = Debug('sockermanager');
|
||||
@ -300,6 +299,9 @@ export class SocketManager {
|
||||
userJoinedZoneMessage.setCharacterlayersList(ProtobufUtils.toCharacterLayerMessages(thing.characterLayers));
|
||||
userJoinedZoneMessage.setPosition(ProtobufUtils.toPositionMessage(thing.getPosition()));
|
||||
userJoinedZoneMessage.setFromzone(this.toProtoZone(fromZone));
|
||||
if (thing.visitCardUrl) {
|
||||
userJoinedZoneMessage.setVisitcardurl(thing.visitCardUrl);
|
||||
}
|
||||
userJoinedZoneMessage.setCompanion(thing.companion);
|
||||
|
||||
const subMessage = new SubToPusherMessage();
|
||||
@ -605,6 +607,9 @@ export class SocketManager {
|
||||
userJoinedMessage.setName(thing.name);
|
||||
userJoinedMessage.setCharacterlayersList(ProtobufUtils.toCharacterLayerMessages(thing.characterLayers));
|
||||
userJoinedMessage.setPosition(ProtobufUtils.toPositionMessage(thing.getPosition()));
|
||||
if (thing.visitCardUrl) {
|
||||
userJoinedMessage.setVisitcardurl(thing.visitCardUrl);
|
||||
}
|
||||
userJoinedMessage.setCompanion(thing.companion);
|
||||
|
||||
const subMessage = new SubToPusherMessage();
|
||||
@ -770,21 +775,6 @@ export class SocketManager {
|
||||
emoteEventMessage.setActoruserid(user.id);
|
||||
room.emitEmoteEvent(user, emoteEventMessage);
|
||||
}
|
||||
|
||||
async handleRequestVisitCardMessage(room: GameRoom, user: User, requestvisitcardmessage: RequestVisitCardMessage): Promise<void> {
|
||||
const targetUser = room.getUserById(requestvisitcardmessage.getTargetuserid());
|
||||
if (!targetUser) {
|
||||
throw 'Could not find user for id '+requestvisitcardmessage.getTargetuserid();
|
||||
}
|
||||
const url = await adminApi.fetchVisitCardUrl(targetUser.uuid);
|
||||
|
||||
const visitCardMessage = new VisitCardMessage();
|
||||
visitCardMessage.setUrl(url);
|
||||
const clientMessage = new ServerToClientMessage();
|
||||
clientMessage.setVisitcardmessage(visitCardMessage);
|
||||
|
||||
user.socket.write(clientMessage);
|
||||
}
|
||||
}
|
||||
|
||||
export const socketManager = new SocketManager();
|
||||
|
@ -1,10 +1,6 @@
|
||||
import "jasmine";
|
||||
import {GameRoom, ConnectCallback, DisconnectCallback } from "_Model/GameRoom";
|
||||
import {Point} from "../src/Model/Websocket/MessageUserPosition";
|
||||
import { Group } from "../src/Model/Group";
|
||||
import {PositionNotifier} from "../src/Model/PositionNotifier";
|
||||
import {User, UserSocket} from "../src/Model/User";
|
||||
import {PointInterface} from "../src/Model/Websocket/PointInterface";
|
||||
import {Zone} from "_Model/Zone";
|
||||
import {Movable} from "_Model/Movable";
|
||||
import {PositionInterface} from "_Model/PositionInterface";
|
||||
@ -30,14 +26,14 @@ describe("PositionNotifier", () => {
|
||||
y: 500,
|
||||
moving: false,
|
||||
direction: 'down'
|
||||
}, false, positionNotifier, {} as UserSocket, [], 'foo', []);
|
||||
}, false, positionNotifier, {} as UserSocket, [], null, 'foo', []);
|
||||
|
||||
const user2 = new User(2, 'test', '10.0.0.2', {
|
||||
x: -9999,
|
||||
y: -9999,
|
||||
moving: false,
|
||||
direction: 'down'
|
||||
}, false, positionNotifier, {} as UserSocket, [], 'foo', []);
|
||||
}, false, positionNotifier, {} as UserSocket, [], null, 'foo', []);
|
||||
|
||||
positionNotifier.addZoneListener({} as ZoneSocket, 0, 0);
|
||||
positionNotifier.addZoneListener({} as ZoneSocket, 0, 1);
|
||||
@ -105,14 +101,14 @@ describe("PositionNotifier", () => {
|
||||
y: 500,
|
||||
moving: false,
|
||||
direction: 'down'
|
||||
}, false, positionNotifier, {} as UserSocket, [], 'foo', []);
|
||||
}, false, positionNotifier, {} as UserSocket, [], null, 'foo', []);
|
||||
|
||||
const user2 = new User(2, 'test', '10.0.0.2', {
|
||||
x: 0,
|
||||
y: 0,
|
||||
moving: false,
|
||||
direction: 'down'
|
||||
}, false, positionNotifier, {} as UserSocket, [], 'foo', []);
|
||||
}, false, positionNotifier, {} as UserSocket, [], null, 'foo', []);
|
||||
|
||||
const listener = {} as ZoneSocket;
|
||||
positionNotifier.addZoneListener(listener, 0, 0);
|
||||
|
@ -44,20 +44,7 @@
|
||||
|
||||
|
||||
<section class="visitCard" transition:fly="{{ y: -200, duration: 1000 }}">
|
||||
{#if visitCardUrl === 'INVALID'}
|
||||
<div class="defaultCard">
|
||||
<header>
|
||||
<h2>Sorry</h2>
|
||||
<p style="font-style: italic;">This user doesn't have a contact card.</p>
|
||||
</header>
|
||||
|
||||
<main style="padding: 5px; background-color: gray">
|
||||
<p>Maybe he is offline, or this feature is deactivated.</p>
|
||||
</main>
|
||||
</div>
|
||||
{:else}
|
||||
<iframe title="visitCardTitle" src={visitCardUrl}></iframe>
|
||||
{/if}
|
||||
<iframe title="visitCardTitle" src={visitCardUrl}></iframe>
|
||||
<div class="buttonContainer">
|
||||
<button class="nes-btn is-popUpElement" on:click={closeCard}>Close</button>
|
||||
</div>
|
||||
|
@ -1,5 +1,3 @@
|
||||
import {PlayerAnimationDirections} from "../Phaser/Player/Animation";
|
||||
import {UserSimplePeerInterface} from "../WebRtc/SimplePeer";
|
||||
import type {SignalData} from "simple-peer";
|
||||
import type {RoomConnection} from "./RoomConnection";
|
||||
import type {BodyResourceDescriptionInterface} from "../Phaser/Entity/PlayerTextures";
|
||||
@ -47,6 +45,7 @@ export interface MessageUserPositionInterface {
|
||||
name: string;
|
||||
characterLayers: BodyResourceDescriptionInterface[];
|
||||
position: PointInterface;
|
||||
visitCardUrl: string|null;
|
||||
companion: string|null;
|
||||
}
|
||||
|
||||
@ -60,6 +59,7 @@ export interface MessageUserJoined {
|
||||
name: string;
|
||||
characterLayers: BodyResourceDescriptionInterface[];
|
||||
position: PointInterface;
|
||||
visitCardUrl: string | null;
|
||||
companion: string|null;
|
||||
}
|
||||
|
||||
@ -85,11 +85,6 @@ export interface WebRtcSignalReceivedMessageInterface {
|
||||
webRtcPassword: string | undefined
|
||||
}
|
||||
|
||||
export interface StartMapInterface {
|
||||
mapUrlStart: string,
|
||||
startInstance: string
|
||||
}
|
||||
|
||||
export interface ViewportInterface {
|
||||
left: number,
|
||||
top: number,
|
||||
|
@ -30,7 +30,7 @@ import {
|
||||
EmoteEventMessage,
|
||||
EmotePromptMessage,
|
||||
SendUserMessage,
|
||||
BanUserMessage, RequestVisitCardMessage
|
||||
BanUserMessage,
|
||||
} from "../Messages/generated/messages_pb"
|
||||
|
||||
import type {UserSimplePeerInterface} from "../WebRtc/SimplePeer";
|
||||
@ -50,7 +50,6 @@ import {worldFullMessageStream} from "./WorldFullMessageStream";
|
||||
import {worldFullWarningStream} from "./WorldFullWarningStream";
|
||||
import {connectionManager} from "./ConnectionManager";
|
||||
import {emoteEventStream} from "./EmoteEventStream";
|
||||
import {requestVisitCardsStore} from "../Stores/GameStore";
|
||||
|
||||
const manualPingDelay = 20000;
|
||||
|
||||
@ -204,8 +203,6 @@ export class RoomConnection implements RoomConnection {
|
||||
adminMessagesService.onSendusermessage(message.getBanusermessage() as BanUserMessage);
|
||||
} else if (message.hasWorldfullwarningmessage()) {
|
||||
worldFullWarningStream.onMessage();
|
||||
} else if (message.hasVisitcardmessage()) {
|
||||
requestVisitCardsStore.set(message?.getVisitcardmessage()?.getUrl() as unknown as string);
|
||||
} else if (message.hasRefreshroommessage()) {
|
||||
//todo: implement a way to notify the user the room was refreshed.
|
||||
} else {
|
||||
@ -347,6 +344,7 @@ export class RoomConnection implements RoomConnection {
|
||||
userId: message.getUserid(),
|
||||
name: message.getName(),
|
||||
characterLayers,
|
||||
visitCardUrl: message.getVisitcardurl(),
|
||||
position: ProtobufClientUtils.toPointInterface(position),
|
||||
companion: companion ? companion.getName() : null
|
||||
}
|
||||
@ -620,14 +618,4 @@ export class RoomConnection implements RoomConnection {
|
||||
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}
|
||||
|
||||
public requestVisitCardUrl(targetUserId: number): void {
|
||||
const message = new RequestVisitCardMessage();
|
||||
message.setTargetuserid(targetUserId);
|
||||
|
||||
const clientToServerMessage = new ClientToServerMessage();
|
||||
clientToServerMessage.setRequestvisitcardmessage(message);
|
||||
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ const TURN_USER: string = process.env.TURN_USER || '';
|
||||
const TURN_PASSWORD: string = process.env.TURN_PASSWORD || '';
|
||||
const JITSI_URL : string|undefined = (process.env.JITSI_URL === '') ? undefined : process.env.JITSI_URL;
|
||||
const JITSI_PRIVATE_MODE : boolean = process.env.JITSI_PRIVATE_MODE == "true";
|
||||
export const DISABLE_VISIT_CARD_FEATURE : boolean = process.env.DISABLE_VISIT_CARD_FEATURE == "true";
|
||||
const POSITION_DELAY = 200; // Wait 200ms between sending position events
|
||||
const MAX_EXTRAPOLATION_TIME = 100; // Extrapolate a maximum of 250ms if no new movement is sent by the player
|
||||
export const MAX_USERNAME_LENGTH = parseInt(process.env.MAX_USERNAME_LENGTH || '') || 8;
|
||||
|
@ -41,6 +41,7 @@ export abstract class Character extends Container {
|
||||
direction: PlayerAnimationDirections,
|
||||
moving: boolean,
|
||||
frame: string | number,
|
||||
isClickable: boolean,
|
||||
companion: string|null,
|
||||
companionTexturePromise?: Promise<string>
|
||||
) {
|
||||
@ -60,7 +61,7 @@ export abstract class Character extends Container {
|
||||
this.playerName.setOrigin(0.5).setDepth(DEPTH_INGAME_TEXT_INDEX);
|
||||
this.add(this.playerName);
|
||||
|
||||
if (this.isClickable()) {
|
||||
if (isClickable) {
|
||||
this.setInteractive({
|
||||
hitArea: new Phaser.Geom.Circle(0, 0, interactiveRadius),
|
||||
hitAreaCallback: Phaser.Geom.Circle.Contains, //eslint-disable-line @typescript-eslint/unbound-method
|
||||
@ -91,8 +92,6 @@ export abstract class Character extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract isClickable(): boolean;
|
||||
|
||||
public addTextures(textures: string[], frame?: string | number): void {
|
||||
for (const texture of textures) {
|
||||
if(!this.scene.textures.exists(texture)){
|
||||
|
@ -2,15 +2,15 @@ import type {GameScene} from "../Game/GameScene";
|
||||
import type {PointInterface} from "../../Connexion/ConnexionModels";
|
||||
import {Character} from "../Entity/Character";
|
||||
import type {PlayerAnimationDirections} from "../Player/Animation";
|
||||
import {DISABLE_VISIT_CARD_FEATURE} from "../../Enum/EnvironmentVariable";
|
||||
import {requestVisitCardsStore} from "../../Stores/GameStore";
|
||||
|
||||
export const playerClickedEvent = 'playerClickedEvent';
|
||||
|
||||
/**
|
||||
* Class representing the sprite of a remote player (a player that plays on another computer)
|
||||
*/
|
||||
export class RemotePlayer extends Character {
|
||||
userId: number;
|
||||
private visitCardUrl: string|null;
|
||||
|
||||
constructor(
|
||||
userId: number,
|
||||
@ -21,16 +21,18 @@ export class RemotePlayer extends Character {
|
||||
texturesPromise: Promise<string[]>,
|
||||
direction: PlayerAnimationDirections,
|
||||
moving: boolean,
|
||||
visitCardUrl: string|null,
|
||||
companion: string|null,
|
||||
companionTexturePromise?: Promise<string>
|
||||
) {
|
||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, companion, companionTexturePromise);
|
||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, !!visitCardUrl, companion, companionTexturePromise);
|
||||
|
||||
//set data
|
||||
this.userId = userId;
|
||||
this.visitCardUrl = visitCardUrl;
|
||||
|
||||
this.on('pointerdown', () => {
|
||||
this.emit(playerClickedEvent, this.userId);
|
||||
requestVisitCardsStore.set(this.visitCardUrl);
|
||||
})
|
||||
}
|
||||
|
||||
@ -45,8 +47,4 @@ export class RemotePlayer extends Character {
|
||||
this.companion.setTarget(position.x, position.y, position.direction as PlayerAnimationDirections);
|
||||
}
|
||||
}
|
||||
|
||||
isClickable(): boolean {
|
||||
return !DISABLE_VISIT_CARD_FEATURE; //todo: make remote players clickable if they are logged in.
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,6 @@ export interface AddPlayerInterface {
|
||||
name: string;
|
||||
characterLayers: BodyResourceDescriptionInterface[];
|
||||
position: PointInterface;
|
||||
visitCardUrl: string|null;
|
||||
companion: string|null;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import type {
|
||||
ITiledMapLayer,
|
||||
ITiledMapLayerProperty,
|
||||
ITiledMapObject,
|
||||
ITiledText,
|
||||
ITiledMapTileLayer,
|
||||
ITiledTileSet
|
||||
} from "../Map/ITiledMap";
|
||||
@ -29,7 +28,7 @@ import type {AddPlayerInterface} from "./AddPlayerInterface";
|
||||
import {PlayerAnimationDirections} from "../Player/Animation";
|
||||
import {PlayerMovement} from "./PlayerMovement";
|
||||
import {PlayersPositionInterpolator} from "./PlayersPositionInterpolator";
|
||||
import {playerClickedEvent, RemotePlayer} from "../Entity/RemotePlayer";
|
||||
import {RemotePlayer} from "../Entity/RemotePlayer";
|
||||
import {Queue} from 'queue-typescript';
|
||||
import {SimplePeer, UserSimplePeerInterface} from "../../WebRtc/SimplePeer";
|
||||
import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene";
|
||||
@ -572,6 +571,7 @@ export class GameScene extends DirtyScene implements CenterListener {
|
||||
characterLayers: message.characterLayers,
|
||||
name: message.name,
|
||||
position: message.position,
|
||||
visitCardUrl: message.visitCardUrl,
|
||||
companion: message.companion
|
||||
}
|
||||
this.addPlayer(userMessage);
|
||||
@ -1376,12 +1376,10 @@ ${escapedMessage}
|
||||
texturesPromise,
|
||||
addPlayerData.position.direction as PlayerAnimationDirections,
|
||||
addPlayerData.position.moving,
|
||||
addPlayerData.visitCardUrl,
|
||||
addPlayerData.companion,
|
||||
addPlayerData.companion !== null ? lazyLoadCompanionResource(this.load, addPlayerData.companion) : undefined
|
||||
);
|
||||
player.on(playerClickedEvent, (userID:number) => {
|
||||
this.connection?.requestVisitCardUrl(userID);
|
||||
})
|
||||
this.MapPlayers.add(player);
|
||||
this.MapPlayersByKey.set(player.userId, player);
|
||||
player.updatePosition(addPlayerData.position);
|
||||
|
@ -26,7 +26,7 @@ export class Player extends Character {
|
||||
companion: string|null,
|
||||
companionTexturePromise?: Promise<string>
|
||||
) {
|
||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, companion, companionTexturePromise);
|
||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise);
|
||||
|
||||
//the current player model should be push away by other players to prevent conflict
|
||||
this.getBody().setImmovable(false);
|
||||
@ -102,10 +102,6 @@ export class Player extends Character {
|
||||
}
|
||||
}
|
||||
|
||||
isClickable(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
openEmoteMenu(emotes:RadialMenuItem[]): void {
|
||||
this.cancelPreviousEmote();
|
||||
this.emoteMenu = new RadialMenu(this.scene, this.x, this.y, emotes)
|
||||
|
@ -75,14 +75,6 @@ message EmoteEventMessage {
|
||||
string emote = 2;
|
||||
}
|
||||
|
||||
message RequestVisitCardMessage {
|
||||
int32 targetUserId = 1;
|
||||
}
|
||||
|
||||
message VisitCardMessage {
|
||||
string url = 1;
|
||||
}
|
||||
|
||||
message QueryJitsiJwtMessage {
|
||||
string jitsiRoom = 1;
|
||||
string tag = 2; // FIXME: rather than reading the tag from the query, we should read it from the current map!
|
||||
@ -102,7 +94,6 @@ message ClientToServerMessage {
|
||||
ReportPlayerMessage reportPlayerMessage = 11;
|
||||
QueryJitsiJwtMessage queryJitsiJwtMessage = 12;
|
||||
EmotePromptMessage emotePromptMessage = 13;
|
||||
RequestVisitCardMessage requestVisitCardMessage = 14;
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,6 +157,7 @@ message UserJoinedMessage {
|
||||
repeated CharacterLayerMessage characterLayers = 3;
|
||||
PositionMessage position = 4;
|
||||
CompanionMessage companion = 5;
|
||||
string visitCardUrl = 6;
|
||||
}
|
||||
|
||||
message UserLeftMessage {
|
||||
@ -268,7 +260,6 @@ message ServerToClientMessage {
|
||||
RefreshRoomMessage refreshRoomMessage = 17;
|
||||
WorldConnexionMessage worldConnexionMessage = 18;
|
||||
EmoteEventMessage emoteEventMessage = 19;
|
||||
VisitCardMessage visitCardMessage = 20;
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,6 +275,7 @@ message JoinRoomMessage {
|
||||
repeated string tag = 6;
|
||||
string IPAddress = 7;
|
||||
CompanionMessage companion = 8;
|
||||
string visitCardUrl = 9;
|
||||
}
|
||||
|
||||
message UserJoinedZoneMessage {
|
||||
@ -293,6 +285,7 @@ message UserJoinedZoneMessage {
|
||||
PositionMessage position = 4;
|
||||
Zone fromZone = 5;
|
||||
CompanionMessage companion = 6;
|
||||
string visitCardUrl = 7;
|
||||
}
|
||||
|
||||
message UserLeftZoneMessage {
|
||||
@ -340,7 +333,6 @@ message PusherToBackMessage {
|
||||
SendUserMessage sendUserMessage = 12;
|
||||
BanUserMessage banUserMessage = 13;
|
||||
EmotePromptMessage emotePromptMessage = 14;
|
||||
RequestVisitCardMessage requestVisitCardMessage = 15;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {CharacterLayer, ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO fix import by "_Model/.."
|
||||
import {GameRoomPolicyTypes, PusherRoom} from "../Model/PusherRoom";
|
||||
import {GameRoomPolicyTypes} from "../Model/PusherRoom";
|
||||
import {PointInterface} from "../Model/Websocket/PointInterface";
|
||||
import {
|
||||
SetPlayerDetailsMessage,
|
||||
@ -12,13 +12,11 @@ import {
|
||||
WebRtcSignalToServerMessage,
|
||||
PlayGlobalMessage,
|
||||
ReportPlayerMessage,
|
||||
EmoteEventMessage,
|
||||
QueryJitsiJwtMessage,
|
||||
SendUserMessage,
|
||||
ServerToClientMessage,
|
||||
CompanionMessage,
|
||||
EmotePromptMessage,
|
||||
RequestVisitCardMessage
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import {UserMovesMessage} from "../Messages/generated/messages_pb";
|
||||
import {TemplatedApp} from "uWebSockets.js"
|
||||
@ -26,7 +24,7 @@ import {parse} from "query-string";
|
||||
import {jwtTokenManager} from "../Services/JWTTokenManager";
|
||||
import {adminApi, CharacterTexture, FetchMemberDataByUuidResponse} from "../Services/AdminApi";
|
||||
import {SocketManager, socketManager} from "../Services/SocketManager";
|
||||
import {emitError, emitInBatch} from "../Services/IoSocketHelpers";
|
||||
import {emitInBatch} from "../Services/IoSocketHelpers";
|
||||
import {ADMIN_API_TOKEN, ADMIN_API_URL, SOCKET_IDLE_TIMER} from "../Enum/EnvironmentVariable";
|
||||
import {Zone} from "_Model/Zone";
|
||||
import {ExAdminSocketInterface} from "_Model/Websocket/ExAdminSocketInterface";
|
||||
@ -169,6 +167,7 @@ export class IoSocketController {
|
||||
const userUuid = await jwtTokenManager.getUserUuidFromToken(token, IPAddress, roomId);
|
||||
|
||||
let memberTags: string[] = [];
|
||||
let memberVisitCardUrl: string|null = null;
|
||||
let memberMessages: unknown;
|
||||
let memberTextures: CharacterTexture[] = [];
|
||||
const room = await socketManager.getOrCreateRoom(roomId);
|
||||
@ -177,6 +176,7 @@ export class IoSocketController {
|
||||
let userData : FetchMemberDataByUuidResponse = {
|
||||
uuid: v4(),
|
||||
tags: [],
|
||||
visitCardUrl: null,
|
||||
textures: [],
|
||||
messages: [],
|
||||
anonymous: true
|
||||
@ -204,6 +204,7 @@ export class IoSocketController {
|
||||
}
|
||||
memberMessages = userData.messages;
|
||||
memberTags = userData.tags;
|
||||
memberVisitCardUrl = userData.visitCardUrl;
|
||||
memberTextures = userData.textures;
|
||||
if (!room.public && room.policyType === GameRoomPolicyTypes.USE_TAGS_POLICY && (userData.anonymous === true || !room.canAccess(memberTags))) {
|
||||
throw new Error('Insufficient privileges to access this room')
|
||||
@ -240,6 +241,7 @@ export class IoSocketController {
|
||||
characterLayers: characterLayerObjs,
|
||||
messages: memberMessages,
|
||||
tags: memberTags,
|
||||
visitCardUrl: memberVisitCardUrl,
|
||||
textures: memberTextures,
|
||||
position: {
|
||||
x: x,
|
||||
@ -338,9 +340,6 @@ export class IoSocketController {
|
||||
socketManager.handleQueryJitsiJwtMessage(client, message.getQueryjitsijwtmessage() as QueryJitsiJwtMessage);
|
||||
} else if (message.hasEmotepromptmessage()){
|
||||
socketManager.handleEmotePromptMessage(client, message.getEmotepromptmessage() as EmotePromptMessage);
|
||||
} else if (message.hasRequestvisitcardmessage()) {
|
||||
|
||||
socketManager.handleRequestVisitCardMessage(client, message.getRequestvisitcardmessage() as RequestVisitCardMessage);
|
||||
}
|
||||
|
||||
/* Ok is false if backpressure was built up, wait for drain */
|
||||
@ -381,6 +380,7 @@ export class IoSocketController {
|
||||
client.messages = ws.messages;
|
||||
client.name = ws.name;
|
||||
client.tags = ws.tags;
|
||||
client.visitCardUrl = ws.visitCardUrl;
|
||||
client.textures = ws.textures;
|
||||
client.characterLayers = ws.characterLayers;
|
||||
client.companion = ws.companion;
|
||||
|
@ -40,6 +40,7 @@ export interface ExSocketInterface extends WebSocket, Identificable {
|
||||
disconnecting: boolean,
|
||||
messages: unknown,
|
||||
tags: string[],
|
||||
visitCardUrl: string|null,
|
||||
textures: CharacterTexture[],
|
||||
backConnection: BackConnection,
|
||||
listenedZones: Set<Zone>;
|
||||
|
@ -30,7 +30,7 @@ export type MovesCallback = (thing: Movable, position: PositionInterface, listen
|
||||
export type LeavesCallback = (thing: Movable, listener: User) => void;*/
|
||||
|
||||
export class UserDescriptor {
|
||||
private constructor(public readonly userId: number, private name: string, private characterLayers: CharacterLayerMessage[], private position: PositionMessage, private companion?: CompanionMessage) {
|
||||
private constructor(public readonly userId: number, private name: string, private characterLayers: CharacterLayerMessage[], private position: PositionMessage, private visitCardUrl: string | null, private companion?: CompanionMessage) {
|
||||
if (!Number.isInteger(this.userId)) {
|
||||
throw new Error('UserDescriptor.userId is not an integer: '+this.userId);
|
||||
}
|
||||
@ -41,7 +41,7 @@ export class UserDescriptor {
|
||||
if (position === undefined) {
|
||||
throw new Error('Missing position');
|
||||
}
|
||||
return new UserDescriptor(message.getUserid(), message.getName(), message.getCharacterlayersList(), position, message.getCompanion());
|
||||
return new UserDescriptor(message.getUserid(), message.getName(), message.getCharacterlayersList(), position, message.getVisitcardurl(), message.getCompanion());
|
||||
}
|
||||
|
||||
public update(userMovedMessage: UserMovedMessage) {
|
||||
@ -59,7 +59,10 @@ export class UserDescriptor {
|
||||
userJoinedMessage.setName(this.name);
|
||||
userJoinedMessage.setCharacterlayersList(this.characterLayers);
|
||||
userJoinedMessage.setPosition(this.position);
|
||||
userJoinedMessage.setCompanion(this.companion)
|
||||
if (this.visitCardUrl) {
|
||||
userJoinedMessage.setVisitcardurl(this.visitCardUrl);
|
||||
}
|
||||
userJoinedMessage.setCompanion(this.companion);
|
||||
|
||||
return userJoinedMessage;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ export interface CharacterTexture {
|
||||
export interface FetchMemberDataByUuidResponse {
|
||||
uuid: string;
|
||||
tags: string[];
|
||||
visitCardUrl: string|null;
|
||||
textures: CharacterTexture[];
|
||||
messages: unknown[];
|
||||
anonymous?: boolean;
|
||||
|
@ -30,7 +30,6 @@ import {
|
||||
BanMessage,
|
||||
RefreshRoomMessage,
|
||||
EmotePromptMessage,
|
||||
RequestVisitCardMessage
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils";
|
||||
import {JITSI_ISS, SECRET_JITSI_KEY} from "../Enum/EnvironmentVariable";
|
||||
@ -162,6 +161,9 @@ export class SocketManager implements ZoneEventListener {
|
||||
joinRoomMessage.setName(client.name);
|
||||
joinRoomMessage.setPositionmessage(ProtobufUtils.toPositionMessage(client.position));
|
||||
joinRoomMessage.setTagList(client.tags);
|
||||
if (client.visitCardUrl) {
|
||||
joinRoomMessage.setVisitcardurl(client.visitCardUrl);
|
||||
}
|
||||
joinRoomMessage.setCompanion(client.companion);
|
||||
|
||||
for (const characterLayer of client.characterLayers) {
|
||||
@ -604,13 +606,6 @@ export class SocketManager implements ZoneEventListener {
|
||||
|
||||
client.backConnection.write(pusherToBackMessage);
|
||||
}
|
||||
|
||||
handleRequestVisitCardMessage(client: ExSocketInterface, requestVisitCardMessage: RequestVisitCardMessage) {
|
||||
const pusherToBackMessage = new PusherToBackMessage();
|
||||
pusherToBackMessage.setRequestvisitcardmessage(requestVisitCardMessage);
|
||||
|
||||
client.backConnection.write(pusherToBackMessage);
|
||||
}
|
||||
}
|
||||
|
||||
export const socketManager = new SocketManager();
|
||||
|
Loading…
Reference in New Issue
Block a user