playGlobalMessage are receive as adminRoomMessage
Suppression of GlobalMessageManager and TypeMessage Migrating message to svelte
This commit is contained in:
parent
6e65952d75
commit
9e16bfc366
@ -212,7 +212,7 @@ const roomManager: IRoomManagerServer = {
|
|||||||
callback(null, new EmptyMessage());
|
callback(null, new EmptyMessage());
|
||||||
},
|
},
|
||||||
sendAdminMessageToRoom(call: ServerUnaryCall<AdminRoomMessage>, callback: sendUnaryData<EmptyMessage>): void {
|
sendAdminMessageToRoom(call: ServerUnaryCall<AdminRoomMessage>, callback: sendUnaryData<EmptyMessage>): void {
|
||||||
socketManager.sendAdminRoomMessage(call.request.getRoomid(), call.request.getMessage());
|
socketManager.sendAdminRoomMessage(call.request.getRoomid(), call.request.getMessage(), call.request.getType());
|
||||||
callback(null, new EmptyMessage());
|
callback(null, new EmptyMessage());
|
||||||
},
|
},
|
||||||
sendWorldFullWarningToRoom(
|
sendWorldFullWarningToRoom(
|
||||||
|
@ -731,7 +731,7 @@ export class SocketManager {
|
|||||||
recipient.socket.end();
|
recipient.socket.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendAdminRoomMessage(roomId: string, message: string) {
|
sendAdminRoomMessage(roomId: string, message: string, type: string) {
|
||||||
const room = this.rooms.get(roomId);
|
const room = this.rooms.get(roomId);
|
||||||
if (!room) {
|
if (!room) {
|
||||||
//todo: this should cause the http call to return a 500
|
//todo: this should cause the http call to return a 500
|
||||||
@ -746,7 +746,7 @@ export class SocketManager {
|
|||||||
room.getUsers().forEach((recipient) => {
|
room.getUsers().forEach((recipient) => {
|
||||||
const sendUserMessage = new SendUserMessage();
|
const sendUserMessage = new SendUserMessage();
|
||||||
sendUserMessage.setMessage(message);
|
sendUserMessage.setMessage(message);
|
||||||
sendUserMessage.setType("message");
|
sendUserMessage.setType(type);
|
||||||
|
|
||||||
const clientMessage = new ServerToClientMessage();
|
const clientMessage = new ServerToClientMessage();
|
||||||
clientMessage.setSendusermessage(sendUserMessage);
|
clientMessage.setSendusermessage(sendUserMessage);
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
import {HtmlUtils} from "./../WebRtc/HtmlUtils";
|
|
||||||
import {PUSHER_URL, UPLOADER_URL} from "../Enum/EnvironmentVariable";
|
|
||||||
import type {RoomConnection} from "../Connexion/RoomConnection";
|
|
||||||
import type {PlayGlobalMessageInterface} from "../Connexion/ConnexionModels";
|
|
||||||
import {soundPlayingStore} from "../Stores/SoundPlayingStore";
|
|
||||||
import {soundManager} from "../Phaser/Game/SoundManager";
|
|
||||||
import {AdminMessageEventTypes} from "../Connexion/AdminMessagesService";
|
|
||||||
|
|
||||||
export class GlobalMessageManager {
|
|
||||||
|
|
||||||
constructor(private Connection: RoomConnection) {
|
|
||||||
this.initialise();
|
|
||||||
}
|
|
||||||
|
|
||||||
initialise(){
|
|
||||||
//receive signal to show message
|
|
||||||
this.Connection.receivePlayGlobalMessage((message: PlayGlobalMessageInterface) => {
|
|
||||||
this.playMessage(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
//receive signal to close message
|
|
||||||
this.Connection.receiveStopGlobalMessage((messageId: string) => {
|
|
||||||
this.stopMessage(messageId);
|
|
||||||
});
|
|
||||||
|
|
||||||
//receive signal to close message
|
|
||||||
this.Connection.receiveTeleportMessage((map: string) => {
|
|
||||||
console.log('map to teleport user', map);
|
|
||||||
//TODO teleport user on map
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private playMessage(message : PlayGlobalMessageInterface){
|
|
||||||
const previousMessage = document.getElementById(this.getHtmlMessageId(message.id));
|
|
||||||
if(previousMessage){
|
|
||||||
previousMessage.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AdminMessageEventTypes.audio === message.type){
|
|
||||||
this.playAudioMessage(message.id, message.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AdminMessageEventTypes.admin === message.type){
|
|
||||||
this.playTextMessage(message.id, message.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private playAudioMessage(messageId : string, urlMessage: string) {
|
|
||||||
soundPlayingStore.playSound(UPLOADER_URL + urlMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private playTextMessage(messageId : string, htmlMessage: string){
|
|
||||||
//add button to clear message
|
|
||||||
const buttonText = document.createElement('p');
|
|
||||||
buttonText.id = 'button-clear-message';
|
|
||||||
buttonText.innerText = 'Clear';
|
|
||||||
|
|
||||||
const buttonMainConsole = document.createElement('div');
|
|
||||||
buttonMainConsole.classList.add('clear');
|
|
||||||
buttonMainConsole.appendChild(buttonText);
|
|
||||||
buttonMainConsole.addEventListener('click', () => {
|
|
||||||
messageContainer.style.top = '-80%';
|
|
||||||
setTimeout(() => {
|
|
||||||
messageContainer.remove();
|
|
||||||
buttonMainConsole.remove();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//create content message
|
|
||||||
const messageCotent = document.createElement('div');
|
|
||||||
messageCotent.innerHTML = htmlMessage;
|
|
||||||
messageCotent.className = "content-message";
|
|
||||||
|
|
||||||
//add message container
|
|
||||||
const messageContainer = document.createElement('div');
|
|
||||||
messageContainer.id = this.getHtmlMessageId(messageId);
|
|
||||||
messageContainer.className = "message-container";
|
|
||||||
messageContainer.appendChild(messageCotent);
|
|
||||||
messageContainer.appendChild(buttonMainConsole);
|
|
||||||
|
|
||||||
const mainSectionDiv = HtmlUtils.getElementByIdOrFail<HTMLDivElement>('main-container');
|
|
||||||
mainSectionDiv.appendChild(messageContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private stopMessage(messageId: string){
|
|
||||||
HtmlUtils.removeElementByIdOrFail<HTMLDivElement>(this.getHtmlMessageId(messageId));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getHtmlMessageId(messageId: string) : string{
|
|
||||||
return `message-${messageId}`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
import type {TypeMessageInterface} from "./UserMessageManager";
|
|
||||||
import {HtmlUtils} from "../WebRtc/HtmlUtils";
|
|
||||||
|
|
||||||
let modalTimeOut : NodeJS.Timeout;
|
|
||||||
|
|
||||||
export class TypeMessageExt implements TypeMessageInterface{
|
|
||||||
private nbSecond = 0;
|
|
||||||
private maxNbSecond = 10;
|
|
||||||
private titleMessage = 'IMPORTANT !';
|
|
||||||
|
|
||||||
showMessage(message: string, canDeleteMessage: boolean = true): void {
|
|
||||||
//delete previous modal
|
|
||||||
try{
|
|
||||||
if(modalTimeOut){
|
|
||||||
clearTimeout(modalTimeOut);
|
|
||||||
}
|
|
||||||
const modal = HtmlUtils.getElementByIdOrFail('report-message-user');
|
|
||||||
modal.remove();
|
|
||||||
}catch (err){
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
//create new modal
|
|
||||||
const div : HTMLDivElement = document.createElement('div');
|
|
||||||
div.classList.add('modal-report-user');
|
|
||||||
div.id = 'report-message-user';
|
|
||||||
div.style.backgroundColor = '#000000e0';
|
|
||||||
|
|
||||||
const img : HTMLImageElement = document.createElement('img');
|
|
||||||
img.src = 'resources/logos/report.svg';
|
|
||||||
div.appendChild(img);
|
|
||||||
|
|
||||||
const title : HTMLParagraphElement = document.createElement('p');
|
|
||||||
title.id = 'title-report-user';
|
|
||||||
title.innerText = `${this.titleMessage} (${this.maxNbSecond})`;
|
|
||||||
div.appendChild(title);
|
|
||||||
|
|
||||||
const p : HTMLParagraphElement = document.createElement('p');
|
|
||||||
p.id = 'body-report-user'
|
|
||||||
p.innerText = message;
|
|
||||||
div.appendChild(p);
|
|
||||||
|
|
||||||
const mainSectionDiv = HtmlUtils.getElementByIdOrFail<HTMLDivElement>('main-container');
|
|
||||||
mainSectionDiv.appendChild(div);
|
|
||||||
|
|
||||||
const reportMessageAudio = HtmlUtils.getElementByIdOrFail<HTMLAudioElement>('report-message');
|
|
||||||
// FIXME: this will fail on iOS
|
|
||||||
// We should move the sound playing into the GameScene and listen to the event of a report using a store
|
|
||||||
try {
|
|
||||||
reportMessageAudio.play();
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.nbSecond = this.maxNbSecond;
|
|
||||||
setTimeout((c) => {
|
|
||||||
this.forMessage(title, canDeleteMessage);
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
forMessage(title: HTMLParagraphElement, canDeleteMessage: boolean = true){
|
|
||||||
this.nbSecond -= 1;
|
|
||||||
title.innerText = `${this.titleMessage} (${this.nbSecond})`;
|
|
||||||
if(this.nbSecond > 0){
|
|
||||||
modalTimeOut = setTimeout(() => {
|
|
||||||
this.forMessage(title, canDeleteMessage);
|
|
||||||
}, 1000);
|
|
||||||
}else {
|
|
||||||
title.innerText = this.titleMessage;
|
|
||||||
|
|
||||||
if (!canDeleteMessage) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const imgCancel: HTMLImageElement = document.createElement('img');
|
|
||||||
imgCancel.id = 'cancel-report-user';
|
|
||||||
imgCancel.src = 'resources/logos/close.svg';
|
|
||||||
|
|
||||||
const div = HtmlUtils.getElementByIdOrFail<HTMLDivElement>('report-message-user');
|
|
||||||
div.appendChild(imgCancel);
|
|
||||||
imgCancel.addEventListener('click', () => {
|
|
||||||
div.remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Message extends TypeMessageExt {}
|
|
||||||
|
|
||||||
export class Ban extends TypeMessageExt {}
|
|
||||||
|
|
||||||
export class Banned extends TypeMessageExt {
|
|
||||||
showMessage(message: string){
|
|
||||||
super.showMessage(message, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +1,34 @@
|
|||||||
import * as TypeMessages from "./TypeMessage";
|
import { AdminMessageEventTypes, adminMessagesService } from "../Connexion/AdminMessagesService";
|
||||||
import {Banned} from "./TypeMessage";
|
import { textMessageContentStore, textMessageVisibleStore } from "../Stores/TypeMessageStore/TextMessageStore";
|
||||||
import {adminMessagesService} from "../Connexion/AdminMessagesService";
|
import { soundPlayingStore } from "../Stores/SoundPlayingStore";
|
||||||
|
import { UPLOADER_URL } from "../Enum/EnvironmentVariable";
|
||||||
export interface TypeMessageInterface {
|
import { banMessageContentStore, banMessageVisibleStore } from "../Stores/TypeMessageStore/BanMessageStore";
|
||||||
showMessage(message: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserMessageManager {
|
class UserMessageManager {
|
||||||
|
|
||||||
typeMessages: Map<string, TypeMessageInterface> = new Map<string, TypeMessageInterface>();
|
|
||||||
receiveBannedMessageListener!: Function;
|
receiveBannedMessageListener!: Function;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const valueTypeMessageTab = Object.values(TypeMessages);
|
|
||||||
Object.keys(TypeMessages).forEach((value: string, index: number) => {
|
|
||||||
const typeMessageInstance: TypeMessageInterface = (new valueTypeMessageTab[index]() as TypeMessageInterface);
|
|
||||||
this.typeMessages.set(value.toLowerCase(), typeMessageInstance);
|
|
||||||
});
|
|
||||||
|
|
||||||
adminMessagesService.messageStream.subscribe((event) => {
|
adminMessagesService.messageStream.subscribe((event) => {
|
||||||
const typeMessage = this.showMessage(event.type, event.text);
|
textMessageVisibleStore.set(false);
|
||||||
if(typeMessage instanceof Banned) {
|
banMessageVisibleStore.set(false);
|
||||||
|
if (event.type === AdminMessageEventTypes.admin) {
|
||||||
|
textMessageContentStore.set(event.text);
|
||||||
|
textMessageVisibleStore.set(true);
|
||||||
|
} else if (event.type === AdminMessageEventTypes.audio) {
|
||||||
|
soundPlayingStore.playSound(UPLOADER_URL + event.text);
|
||||||
|
} else if (event.type === AdminMessageEventTypes.ban) {
|
||||||
|
banMessageContentStore.set(event.text);
|
||||||
|
banMessageVisibleStore.set(true);
|
||||||
|
} else if (event.type === AdminMessageEventTypes.banned) {
|
||||||
|
banMessageContentStore.set(event.text);
|
||||||
|
banMessageVisibleStore.set(true);
|
||||||
this.receiveBannedMessageListener();
|
this.receiveBannedMessageListener();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showMessage(type: string, message: string) {
|
setReceiveBanListener(callback: Function) {
|
||||||
const classTypeMessage = this.typeMessages.get(type.toLowerCase());
|
|
||||||
if (!classTypeMessage) {
|
|
||||||
console.error('Message unknown');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
classTypeMessage.showMessage(message);
|
|
||||||
return classTypeMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
setReceiveBanListener(callback: Function){
|
|
||||||
this.receiveBannedMessageListener = callback;
|
this.receiveBannedMessageListener = callback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const userMessageManager = new UserMessageManager()
|
export const userMessageManager = new UserMessageManager();
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
import {gameOverlayVisibilityStore} from "../Stores/GameOverlayStoreVisibility";
|
import {gameOverlayVisibilityStore} from "../Stores/GameOverlayStoreVisibility";
|
||||||
import {consoleGlobalMessageManagerVisibleStore} from "../Stores/ConsoleGlobalMessageManagerStore";
|
import {consoleGlobalMessageManagerVisibleStore} from "../Stores/ConsoleGlobalMessageManagerStore";
|
||||||
import ConsoleGlobalMessageManager from "./ConsoleGlobalMessageManager/ConsoleGlobalMessageManager.svelte";
|
import ConsoleGlobalMessageManager from "./ConsoleGlobalMessageManager/ConsoleGlobalMessageManager.svelte";
|
||||||
|
import AdminMessage from "./TypeMessage/BanMessage.svelte";
|
||||||
|
import TextMessage from "./TypeMessage/TextMessage.svelte";
|
||||||
|
import {banMessageVisibleStore} from "../Stores/TypeMessageStore/BanMessageStore";
|
||||||
|
import {textMessageVisibleStore} from "../Stores/TypeMessageStore/TextMessageStore";
|
||||||
|
|
||||||
export let game: Game;
|
export let game: Game;
|
||||||
|
|
||||||
@ -58,6 +62,16 @@
|
|||||||
<EnableCameraScene game={game}></EnableCameraScene>
|
<EnableCameraScene game={game}></EnableCameraScene>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if $banMessageVisibleStore}
|
||||||
|
<div>
|
||||||
|
<AdminMessage></AdminMessage>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if $textMessageVisibleStore}
|
||||||
|
<div>
|
||||||
|
<TextMessage></TextMessage>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{#if $soundPlayingStore}
|
{#if $soundPlayingStore}
|
||||||
<div>
|
<div>
|
||||||
<AudioPlaying url={$soundPlayingStore} />
|
<AudioPlaying url={$soundPlayingStore} />
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
let inputSendTextActive = true;
|
let inputSendTextActive = true;
|
||||||
let uploadMusicActive = false;
|
let uploadMusicActive = false;
|
||||||
let handleSendText: { sendTextMessage(broadcast: boolean): void };
|
let handleSendText: { sendTextMessage(broadcast: boolean): void };
|
||||||
let handleSendAudio: { sendAudioMessage(): Promise<void> };
|
let handleSendAudio: { sendAudioMessage(broadcast: boolean): Promise<void> };
|
||||||
let broadcastToWorld = false;
|
let broadcastToWorld = false;
|
||||||
|
|
||||||
function closeConsoleGlobalMessage() {
|
function closeConsoleGlobalMessage() {
|
||||||
@ -38,7 +38,7 @@
|
|||||||
handleSendText.sendTextMessage(broadcastToWorld);
|
handleSendText.sendTextMessage(broadcastToWorld);
|
||||||
}
|
}
|
||||||
if (uploadMusicActive) {
|
if (uploadMusicActive) {
|
||||||
handleSendAudio.sendAudioMessage();
|
handleSendAudio.sendAudioMessage(broadcastToWorld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import type { Game } from "../../Phaser/Game/Game";
|
import type { Game } from "../../Phaser/Game/Game";
|
||||||
import type { GameManager } from "../../Phaser/Game/GameManager";
|
import type { GameManager } from "../../Phaser/Game/GameManager";
|
||||||
import type { UserGlobalMessageInterface } from "../../Connexion/ConnexionModels";
|
|
||||||
import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService";
|
import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService";
|
||||||
import type { Quill } from "quill";
|
import type { Quill } from "quill";
|
||||||
|
import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels";
|
||||||
|
|
||||||
//toolbar
|
//toolbar
|
||||||
const toolbarOptions = [
|
const toolbarOptions = [
|
||||||
@ -46,15 +46,19 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const text = quill.getText(0, quill.getLength());
|
const text = quill.getText(0, quill.getLength());
|
||||||
|
const content = quill.getContents(0, quill.getLength());
|
||||||
|
|
||||||
const textGlobalMessage: UserGlobalMessageInterface = {
|
console.log('Text : ', text);
|
||||||
|
console.log('Content : ', content);
|
||||||
|
|
||||||
|
const textGlobalMessage: PlayGlobalMessageInterface = {
|
||||||
type: MESSAGE_TYPE,
|
type: MESSAGE_TYPE,
|
||||||
content: text,
|
content: text,
|
||||||
broadcastToWorld: broadcastToWorld
|
broadcastToWorld: broadcastToWorld
|
||||||
};
|
};
|
||||||
|
|
||||||
quill.deleteText(0, quill.getLength());
|
quill.deleteText(0, quill.getLength());
|
||||||
gameScene.connection?.sendUserGlobalMessage(textGlobalMessage);
|
gameScene.connection?.emitGlobalMessage(textGlobalMessage);
|
||||||
disableConsole();
|
disableConsole();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
import type { GameManager } from "../../Phaser/Game/GameManager";
|
import type { GameManager } from "../../Phaser/Game/GameManager";
|
||||||
import { consoleGlobalMessageManagerFocusStore, consoleGlobalMessageManagerVisibleStore } from "../../Stores/ConsoleGlobalMessageManagerStore";
|
import { consoleGlobalMessageManagerFocusStore, consoleGlobalMessageManagerVisibleStore } from "../../Stores/ConsoleGlobalMessageManagerStore";
|
||||||
import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService";
|
import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService";
|
||||||
import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels";
|
|
||||||
import uploadFile from "../images/music-file.svg";
|
import uploadFile from "../images/music-file.svg";
|
||||||
|
import type {PlayGlobalMessageInterface} from "../../Connexion/ConnexionModels";
|
||||||
|
|
||||||
interface EventTargetFiles extends EventTarget {
|
interface EventTargetFiles extends EventTarget {
|
||||||
files: Array<File>;
|
files: Array<File>;
|
||||||
@ -23,7 +23,7 @@
|
|||||||
const AUDIO_TYPE = AdminMessageEventTypes.audio;
|
const AUDIO_TYPE = AdminMessageEventTypes.audio;
|
||||||
|
|
||||||
export const handleSending = {
|
export const handleSending = {
|
||||||
async sendAudioMessage() {
|
async sendAudioMessage(broadcast: boolean) {
|
||||||
if (gameScene == undefined) {
|
if (gameScene == undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -38,13 +38,13 @@
|
|||||||
fd.append('file', selectedFile);
|
fd.append('file', selectedFile);
|
||||||
const res = await gameScene.connection?.uploadAudio(fd);
|
const res = await gameScene.connection?.uploadAudio(fd);
|
||||||
|
|
||||||
const GlobalMessage: PlayGlobalMessageInterface = {
|
const audioGlobalMessage: PlayGlobalMessageInterface = {
|
||||||
id: (res as { id: string }).id,
|
content: (res as { path: string }).path,
|
||||||
message: (res as { path: string }).path,
|
type: AUDIO_TYPE,
|
||||||
type: AUDIO_TYPE
|
broadcastToWorld: broadcast
|
||||||
}
|
}
|
||||||
inputAudio.value = '';
|
inputAudio.value = '';
|
||||||
gameScene.connection?.emitGlobalMessage(GlobalMessage);
|
gameScene.connection?.emitGlobalMessage(audioGlobalMessage);
|
||||||
disableConsole();
|
disableConsole();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
89
front/src/Components/TypeMessage/BanMessage.svelte
Normal file
89
front/src/Components/TypeMessage/BanMessage.svelte
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { fly } from "svelte/transition";
|
||||||
|
import {banMessageVisibleStore, banMessageContentStore} from "../../Stores/TypeMessageStore/BanMessageStore";
|
||||||
|
import {onMount} from "svelte";
|
||||||
|
|
||||||
|
const text = $banMessageContentStore;
|
||||||
|
const NAME_BUTTON = 'Ok';
|
||||||
|
let nbSeconds = 10;
|
||||||
|
let nameButton = '';
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
timeToRead()
|
||||||
|
})
|
||||||
|
|
||||||
|
function timeToRead() {
|
||||||
|
nbSeconds -= 1;
|
||||||
|
nameButton = nbSeconds.toString();
|
||||||
|
if ( nbSeconds > 0 ) {
|
||||||
|
setTimeout( () => {
|
||||||
|
timeToRead();
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
nameButton = NAME_BUTTON;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeBanMessage() {
|
||||||
|
banMessageVisibleStore.set(false);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="main-ban-message nes-container is-rounded" transition:fly="{{ y: -1000, duration: 500 }}">
|
||||||
|
<h2 class="title-ban-message"><img src="resources/logos/report.svg" alt="***"/> Important message <img src="resources/logos/report.svg" alt="***"/></h2>
|
||||||
|
<div class="content-ban-message">
|
||||||
|
{text}
|
||||||
|
</div>
|
||||||
|
<div class="footer-ban-message">
|
||||||
|
<button type="button" class="nes-btn {nameButton === NAME_BUTTON ? 'is-primary' : 'is-error'}" disabled="{!(nameButton === NAME_BUTTON)}" on:click|preventDefault={closeBanMessage}>{nameButton}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
div.main-ban-message {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
position: relative;
|
||||||
|
top: 15vh;
|
||||||
|
|
||||||
|
height: 70vh;
|
||||||
|
width: 60vw;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
padding-bottom: 0;
|
||||||
|
|
||||||
|
pointer-events: auto;
|
||||||
|
background-color: #333333;
|
||||||
|
color: whitesmoke;
|
||||||
|
|
||||||
|
h2.title-ban-message {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
max-height: 50px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
img {
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.content-ban-message {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
max-height: calc(100% - 50px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.footer-ban-message {
|
||||||
|
height: 50px;
|
||||||
|
margin-top: 10px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 88px;
|
||||||
|
height: 44px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
57
front/src/Components/TypeMessage/TextMessage.svelte
Normal file
57
front/src/Components/TypeMessage/TextMessage.svelte
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { fly } from "svelte/transition";
|
||||||
|
import {textMessageContentStore, textMessageVisibleStore} from "../../Stores/TypeMessageStore/TextMessageStore";
|
||||||
|
|
||||||
|
const text = $textMessageContentStore;
|
||||||
|
const NAME_BUTTON = 'Ok';
|
||||||
|
|
||||||
|
function closeTextMessage() {
|
||||||
|
textMessageVisibleStore.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onKeyDown(e:KeyboardEvent) {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
closeTextMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:keydown={onKeyDown}/>
|
||||||
|
|
||||||
|
<div class="main-text-message nes-container is-rounded" transition:fly="{{ x: -1000, duration: 500 }}">
|
||||||
|
<div class="content-text-message">
|
||||||
|
<p> {text} </p>
|
||||||
|
</div>
|
||||||
|
<div class="footer-text-message">
|
||||||
|
<button type="button" class="nes-btn is-primary" on:click|preventDefault={closeTextMessage}>{NAME_BUTTON}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
div.main-text-message {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
max-height: 25vh;
|
||||||
|
width: 80vw;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
padding-bottom: 0;
|
||||||
|
|
||||||
|
pointer-events: auto;
|
||||||
|
background-color: #333333;
|
||||||
|
|
||||||
|
div.content-text-message {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
max-height: calc(100% - 50px);
|
||||||
|
color: whitesmoke;
|
||||||
|
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.footer-text-message {
|
||||||
|
height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -108,12 +108,6 @@ export interface RoomJoinedMessageInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface PlayGlobalMessageInterface {
|
export interface PlayGlobalMessageInterface {
|
||||||
id: string;
|
|
||||||
type: string;
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserGlobalMessageInterface {
|
|
||||||
type: string;
|
type: string;
|
||||||
content: string;
|
content: string;
|
||||||
broadcastToWorld: boolean;
|
broadcastToWorld: boolean;
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
GroupUpdateMessage,
|
GroupUpdateMessage,
|
||||||
ItemEventMessage,
|
ItemEventMessage,
|
||||||
PlayGlobalMessage,
|
PlayGlobalMessage,
|
||||||
UserGlobalMessage,
|
|
||||||
PositionMessage,
|
PositionMessage,
|
||||||
RoomJoinedMessage,
|
RoomJoinedMessage,
|
||||||
ServerToClientMessage,
|
ServerToClientMessage,
|
||||||
@ -45,7 +44,6 @@ import {
|
|||||||
MessageUserJoined,
|
MessageUserJoined,
|
||||||
OnConnectInterface,
|
OnConnectInterface,
|
||||||
PlayGlobalMessageInterface,
|
PlayGlobalMessageInterface,
|
||||||
UserGlobalMessageInterface,
|
|
||||||
PositionInterface,
|
PositionInterface,
|
||||||
RoomJoinedMessageInterface,
|
RoomJoinedMessageInterface,
|
||||||
ViewportInterface,
|
ViewportInterface,
|
||||||
@ -560,7 +558,7 @@ export class RoomConnection implements RoomConnection {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public receivePlayGlobalMessage(callback: (message: PlayGlobalMessageInterface) => void) {
|
/* public receivePlayGlobalMessage(callback: (message: PlayGlobalMessageInterface) => void) {
|
||||||
return this.onMessage(EventMessage.PLAY_GLOBAL_MESSAGE, (message: PlayGlobalMessage) => {
|
return this.onMessage(EventMessage.PLAY_GLOBAL_MESSAGE, (message: PlayGlobalMessage) => {
|
||||||
callback({
|
callback({
|
||||||
id: message.getId(),
|
id: message.getId(),
|
||||||
@ -568,7 +566,7 @@ export class RoomConnection implements RoomConnection {
|
|||||||
message: message.getMessage(),
|
message: message.getMessage(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public receiveStopGlobalMessage(callback: (messageId: string) => void) {
|
public receiveStopGlobalMessage(callback: (messageId: string) => void) {
|
||||||
return this.onMessage(EventMessage.STOP_GLOBAL_MESSAGE, (message: StopGlobalMessage) => {
|
return this.onMessage(EventMessage.STOP_GLOBAL_MESSAGE, (message: StopGlobalMessage) => {
|
||||||
@ -582,11 +580,11 @@ export class RoomConnection implements RoomConnection {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public emitGlobalMessage(message: PlayGlobalMessageInterface) {
|
public emitGlobalMessage(message: PlayGlobalMessageInterface): void {
|
||||||
const playGlobalMessage = new PlayGlobalMessage();
|
const playGlobalMessage = new PlayGlobalMessage();
|
||||||
playGlobalMessage.setId(message.id);
|
|
||||||
playGlobalMessage.setType(message.type);
|
playGlobalMessage.setType(message.type);
|
||||||
playGlobalMessage.setMessage(message.message);
|
playGlobalMessage.setContent(message.content);
|
||||||
|
playGlobalMessage.setBroadcasttoworld(message.broadcastToWorld);
|
||||||
|
|
||||||
const clientToServerMessage = new ClientToServerMessage();
|
const clientToServerMessage = new ClientToServerMessage();
|
||||||
clientToServerMessage.setPlayglobalmessage(playGlobalMessage);
|
clientToServerMessage.setPlayglobalmessage(playGlobalMessage);
|
||||||
@ -645,16 +643,4 @@ export class RoomConnection implements RoomConnection {
|
|||||||
public getAllTags(): string[] {
|
public getAllTags(): string[] {
|
||||||
return this.tags;
|
return this.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sendUserGlobalMessage(message: UserGlobalMessageInterface): void {
|
|
||||||
const userGlobalMessage = new UserGlobalMessage();
|
|
||||||
userGlobalMessage.setType(message.type);
|
|
||||||
userGlobalMessage.setContent(message.content);
|
|
||||||
userGlobalMessage.setBroadcasttoworld(message.broadcastToWorld);
|
|
||||||
|
|
||||||
const clientToServerMessage = new ClientToServerMessage();
|
|
||||||
clientToServerMessage.setUserglobalmessage(userGlobalMessage);
|
|
||||||
|
|
||||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import type { Subscription } from "rxjs";
|
import type { Subscription } from "rxjs";
|
||||||
import { GlobalMessageManager } from "../../Administration/GlobalMessageManager";
|
|
||||||
import { userMessageManager } from "../../Administration/UserMessageManager";
|
import { userMessageManager } from "../../Administration/UserMessageManager";
|
||||||
import { iframeListener } from "../../Api/IframeListener";
|
import { iframeListener } from "../../Api/IframeListener";
|
||||||
import { connectionManager } from "../../Connexion/ConnectionManager";
|
import { connectionManager } from "../../Connexion/ConnectionManager";
|
||||||
@ -160,7 +159,6 @@ export class GameScene extends DirtyScene {
|
|||||||
private playersPositionInterpolator = new PlayersPositionInterpolator();
|
private playersPositionInterpolator = new PlayersPositionInterpolator();
|
||||||
public connection: RoomConnection | undefined;
|
public connection: RoomConnection | undefined;
|
||||||
private simplePeer!: SimplePeer;
|
private simplePeer!: SimplePeer;
|
||||||
private GlobalMessageManager!: GlobalMessageManager;
|
|
||||||
private connectionAnswerPromise: Promise<RoomJoinedMessageInterface>;
|
private connectionAnswerPromise: Promise<RoomJoinedMessageInterface>;
|
||||||
private connectionAnswerPromiseResolve!: (
|
private connectionAnswerPromiseResolve!: (
|
||||||
value: RoomJoinedMessageInterface | PromiseLike<RoomJoinedMessageInterface>
|
value: RoomJoinedMessageInterface | PromiseLike<RoomJoinedMessageInterface>
|
||||||
@ -694,7 +692,6 @@ export class GameScene extends DirtyScene {
|
|||||||
peerStore.connectToSimplePeer(this.simplePeer);
|
peerStore.connectToSimplePeer(this.simplePeer);
|
||||||
screenSharingPeerStore.connectToSimplePeer(this.simplePeer);
|
screenSharingPeerStore.connectToSimplePeer(this.simplePeer);
|
||||||
videoFocusStore.connectToSimplePeer(this.simplePeer);
|
videoFocusStore.connectToSimplePeer(this.simplePeer);
|
||||||
this.GlobalMessageManager = new GlobalMessageManager(this.connection);
|
|
||||||
userMessageManager.setReceiveBanListener(this.bannedUser.bind(this));
|
userMessageManager.setReceiveBanListener(this.bannedUser.bind(this));
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
5
front/src/Stores/TypeMessageStore/BanMessageStore.ts
Normal file
5
front/src/Stores/TypeMessageStore/BanMessageStore.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
|
export const banMessageVisibleStore = writable(false);
|
||||||
|
|
||||||
|
export const banMessageContentStore = writable("");
|
5
front/src/Stores/TypeMessageStore/TextMessageStore.ts
Normal file
5
front/src/Stores/TypeMessageStore/TextMessageStore.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
|
export const textMessageVisibleStore = writable(false);
|
||||||
|
|
||||||
|
export const textMessageContentStore = writable("");
|
@ -94,7 +94,6 @@ message ClientToServerMessage {
|
|||||||
ReportPlayerMessage reportPlayerMessage = 11;
|
ReportPlayerMessage reportPlayerMessage = 11;
|
||||||
QueryJitsiJwtMessage queryJitsiJwtMessage = 12;
|
QueryJitsiJwtMessage queryJitsiJwtMessage = 12;
|
||||||
EmotePromptMessage emotePromptMessage = 13;
|
EmotePromptMessage emotePromptMessage = 13;
|
||||||
UserGlobalMessage userGlobalMessage = 14;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,12 +108,6 @@ message ItemEventMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message PlayGlobalMessage {
|
message PlayGlobalMessage {
|
||||||
string id = 1;
|
|
||||||
string type = 2;
|
|
||||||
string message = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UserGlobalMessage {
|
|
||||||
string type = 1;
|
string type = 1;
|
||||||
string content = 2;
|
string content = 2;
|
||||||
bool broadcastToWorld = 3;
|
bool broadcastToWorld = 3;
|
||||||
@ -267,7 +260,6 @@ message ServerToClientMessage {
|
|||||||
RefreshRoomMessage refreshRoomMessage = 17;
|
RefreshRoomMessage refreshRoomMessage = 17;
|
||||||
WorldConnexionMessage worldConnexionMessage = 18;
|
WorldConnexionMessage worldConnexionMessage = 18;
|
||||||
EmoteEventMessage emoteEventMessage = 19;
|
EmoteEventMessage emoteEventMessage = 19;
|
||||||
UserGlobalMessage userGlobalMessage = 20;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +334,6 @@ message PusherToBackMessage {
|
|||||||
SendUserMessage sendUserMessage = 12;
|
SendUserMessage sendUserMessage = 12;
|
||||||
BanUserMessage banUserMessage = 13;
|
BanUserMessage banUserMessage = 13;
|
||||||
EmotePromptMessage emotePromptMessage = 14;
|
EmotePromptMessage emotePromptMessage = 14;
|
||||||
UserGlobalMessage userGlobalMessage = 15;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,6 +406,7 @@ message AdminMessage {
|
|||||||
message AdminRoomMessage {
|
message AdminRoomMessage {
|
||||||
string message = 1;
|
string message = 1;
|
||||||
string roomId = 2;
|
string roomId = 2;
|
||||||
|
string type = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A message sent by an administrator to absolutely everybody
|
// A message sent by an administrator to absolutely everybody
|
||||||
|
@ -17,7 +17,6 @@ import {
|
|||||||
ServerToClientMessage,
|
ServerToClientMessage,
|
||||||
CompanionMessage,
|
CompanionMessage,
|
||||||
EmotePromptMessage,
|
EmotePromptMessage,
|
||||||
UserGlobalMessage,
|
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
||||||
import { TemplatedApp } from "uWebSockets.js";
|
import { TemplatedApp } from "uWebSockets.js";
|
||||||
@ -382,8 +381,6 @@ export class IoSocketController {
|
|||||||
client,
|
client,
|
||||||
message.getEmotepromptmessage() as EmotePromptMessage
|
message.getEmotepromptmessage() as EmotePromptMessage
|
||||||
);
|
);
|
||||||
} else if (message.hasUserglobalmessage()) {
|
|
||||||
socketManager.handleUserGlobalMessage(client, message.getUserglobalmessage() as UserGlobalMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ok is false if backpressure was built up, wait for drain */
|
/* Ok is false if backpressure was built up, wait for drain */
|
||||||
|
@ -23,7 +23,6 @@ import {
|
|||||||
SetPlayerDetailsMessage,
|
SetPlayerDetailsMessage,
|
||||||
SilentMessage,
|
SilentMessage,
|
||||||
SubMessage,
|
SubMessage,
|
||||||
UserGlobalMessage,
|
|
||||||
UserJoinedRoomMessage,
|
UserJoinedRoomMessage,
|
||||||
UserLeftMessage,
|
UserLeftMessage,
|
||||||
UserLeftRoomMessage,
|
UserLeftRoomMessage,
|
||||||
@ -387,17 +386,6 @@ export class SocketManager implements ZoneEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emitPlayGlobalMessage(client: ExSocketInterface, playglobalmessage: PlayGlobalMessage) {
|
|
||||||
if (!client.tags.includes("admin")) {
|
|
||||||
//In case of xss injection, we just kill the connection.
|
|
||||||
throw "Client is not an admin!";
|
|
||||||
}
|
|
||||||
const pusherToBackMessage = new PusherToBackMessage();
|
|
||||||
pusherToBackMessage.setPlayglobalmessage(playglobalmessage);
|
|
||||||
|
|
||||||
client.backConnection.write(pusherToBackMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getWorlds(): Map<string, PusherRoom> {
|
public getWorlds(): Map<string, PusherRoom> {
|
||||||
return this.rooms;
|
return this.rooms;
|
||||||
}
|
}
|
||||||
@ -607,9 +595,9 @@ export class SocketManager implements ZoneEventListener {
|
|||||||
client.backConnection.write(pusherToBackMessage);
|
client.backConnection.write(pusherToBackMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleUserGlobalMessage(
|
public async emitPlayGlobalMessage(
|
||||||
client: ExSocketInterface,
|
client: ExSocketInterface,
|
||||||
userGlobalMessageEvent: UserGlobalMessage
|
playGlobalMessageEvent: PlayGlobalMessage
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!client.tags.includes("admin")) {
|
if (!client.tags.includes("admin")) {
|
||||||
throw "Client is not an admin!";
|
throw "Client is not an admin!";
|
||||||
@ -618,14 +606,15 @@ export class SocketManager implements ZoneEventListener {
|
|||||||
const clientRoomUrl = client.roomId;
|
const clientRoomUrl = client.roomId;
|
||||||
let tabUrlRooms: string[];
|
let tabUrlRooms: string[];
|
||||||
|
|
||||||
if (userGlobalMessageEvent.getBroadcasttoworld()) {
|
if (playGlobalMessageEvent.getBroadcasttoworld()) {
|
||||||
tabUrlRooms = await adminApi.getUrlRoomsFromSameWorld(clientRoomUrl);
|
tabUrlRooms = await adminApi.getUrlRoomsFromSameWorld(clientRoomUrl);
|
||||||
} else {
|
} else {
|
||||||
tabUrlRooms = [clientRoomUrl];
|
tabUrlRooms = [clientRoomUrl];
|
||||||
}
|
}
|
||||||
|
|
||||||
let roomMessage = new AdminRoomMessage();
|
let roomMessage = new AdminRoomMessage();
|
||||||
roomMessage.setMessage(userGlobalMessageEvent.getContent());
|
roomMessage.setMessage(playGlobalMessageEvent.getContent());
|
||||||
|
roomMessage.setType(playGlobalMessageEvent.getType());
|
||||||
|
|
||||||
for (let roomUrl of tabUrlRooms) {
|
for (let roomUrl of tabUrlRooms) {
|
||||||
let apiRoom = await apiClientRepository.getClient(roomUrl);
|
let apiRoom = await apiClientRepository.getClient(roomUrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user