Merge branch 'develop' of github.com:thecodingmachine/workadventure into feature/global-message
+ migrating to protobuf messages # Conflicts: # back/src/App.ts # back/src/Controller/IoSocketController.ts # back/yarn.lock # front/src/Connection.ts # front/src/Phaser/Game/GameScene.ts # front/src/Phaser/Login/EnableCameraScene.ts # front/src/WebRtc/SimplePeer.ts
This commit is contained in:
commit
d3fa901691
87 changed files with 7429 additions and 1891 deletions
|
@ -3,8 +3,9 @@ import {GameScene} from "../Phaser/Game/GameScene";
|
|||
const Quill = require("quill");
|
||||
|
||||
import {HtmlUtils} from "../WebRtc/HtmlUtils";
|
||||
import {Connection, GlobalMessageInterface} from "../Connection";
|
||||
import {UserInputManager} from "../Phaser/UserInput/UserInputManager";
|
||||
import {RoomConnection} from "../Connexion/RoomConnection";
|
||||
import {PlayGlobalMessageInterface} from "../Connexion/ConnexionModels";
|
||||
|
||||
export const CLASS_CONSOLE_MESSAGE = 'main-console';
|
||||
export const INPUT_CONSOLE_MESSAGE = 'input-send-text';
|
||||
|
@ -21,14 +22,12 @@ interface EventTargetFiles extends EventTarget {
|
|||
|
||||
export class ConsoleGlobalMessageManager {
|
||||
|
||||
private Connection: Connection;
|
||||
private divMainConsole: HTMLDivElement;
|
||||
private buttonMainConsole: HTMLDivElement;
|
||||
private activeConsole: boolean = false;
|
||||
private userInputManager!: UserInputManager;
|
||||
|
||||
constructor(Connection: Connection, userInputManager : UserInputManager) {
|
||||
this.Connection = Connection;
|
||||
constructor(private Connection: RoomConnection, userInputManager : UserInputManager) {
|
||||
this.buttonMainConsole = document.createElement('div');
|
||||
this.buttonMainConsole.classList.add('console');
|
||||
this.divMainConsole = document.createElement('div');
|
||||
|
@ -240,8 +239,8 @@ export class ConsoleGlobalMessageManager {
|
|||
if(!quillEditor){
|
||||
throw "Error get quill node";
|
||||
}
|
||||
const GlobalMessage : GlobalMessageInterface = {
|
||||
id: 1,
|
||||
const GlobalMessage : PlayGlobalMessageInterface = {
|
||||
id: "1", // FIXME: use another ID?
|
||||
message: quillEditor.innerHTML,
|
||||
type: MESSAGE_TYPE
|
||||
};
|
||||
|
@ -260,8 +259,8 @@ export class ConsoleGlobalMessageManager {
|
|||
fd.append('file', selectedFile);
|
||||
const res = await this.Connection.uploadAudio(fd);
|
||||
|
||||
const GlobalMessage : GlobalMessageInterface = {
|
||||
id: (res as {id: number}).id,
|
||||
const GlobalMessage : PlayGlobalMessageInterface = {
|
||||
id: (res as {id: string}).id,
|
||||
message: (res as {path: string}).path,
|
||||
type: AUDIO_TYPE
|
||||
};
|
||||
|
@ -302,4 +301,4 @@ export class ConsoleGlobalMessageManager {
|
|||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
import {HtmlUtils} from "./../WebRtc/HtmlUtils";
|
||||
import {Connection, GlobalMessageInterface} from "../Connection";
|
||||
import {AUDIO_TYPE, MESSAGE_TYPE} from "./ConsoleGlobalMessageManager";
|
||||
import {API_URL} from "../Enum/EnvironmentVariable";
|
||||
import {RoomConnection} from "../Connexion/RoomConnection";
|
||||
import {PlayGlobalMessageInterface} from "../Connexion/ConnexionModels";
|
||||
|
||||
export class GlobalMessageManager {
|
||||
|
||||
private Connection: Connection;
|
||||
|
||||
constructor(Connection: Connection) {
|
||||
this.Connection = Connection;
|
||||
constructor(private Connection: RoomConnection) {
|
||||
this.initialise();
|
||||
}
|
||||
|
||||
initialise(){
|
||||
//receive signal to show message
|
||||
this.Connection.receivePlayGlobalMessage((message: GlobalMessageInterface) => {
|
||||
this.Connection.receivePlayGlobalMessage((message: PlayGlobalMessageInterface) => {
|
||||
this.playMessage(message);
|
||||
});
|
||||
|
||||
//receive signal to close message
|
||||
this.Connection.receiveStopGlobalMessage((message: GlobalMessageInterface) => {
|
||||
this.stopMessage(message.id);
|
||||
this.Connection.receiveStopGlobalMessage((messageId: string) => {
|
||||
this.stopMessage(messageId);
|
||||
});
|
||||
}
|
||||
|
||||
private playMessage(message : GlobalMessageInterface){
|
||||
private playMessage(message : PlayGlobalMessageInterface){
|
||||
const previousMessage = document.getElementById(this.getHtmlMessageId(message.id));
|
||||
if(previousMessage){
|
||||
previousMessage.remove();
|
||||
|
@ -39,7 +37,7 @@ export class GlobalMessageManager {
|
|||
}
|
||||
}
|
||||
|
||||
private playAudioMessage(messageId : number, urlMessage: string){
|
||||
private playAudioMessage(messageId : string, urlMessage: string){
|
||||
//delete previous elements
|
||||
const previousDivAudio = document.getElementsByClassName('audio-playing');
|
||||
for(let i = 0; i < previousDivAudio.length; i++){
|
||||
|
@ -80,7 +78,7 @@ export class GlobalMessageManager {
|
|||
mainSectionDiv.appendChild(messageAudio);
|
||||
}
|
||||
|
||||
private playTextMessage(messageId : number, htmlMessage: string){
|
||||
private playTextMessage(messageId : string, htmlMessage: string){
|
||||
//add button to clear message
|
||||
const buttonText = document.createElement('p');
|
||||
buttonText.id = 'button-clear-message';
|
||||
|
@ -113,12 +111,11 @@ export class GlobalMessageManager {
|
|||
mainSectionDiv.appendChild(messageContainer);
|
||||
}
|
||||
|
||||
private stopMessage(messageId: number){
|
||||
private stopMessage(messageId: string){
|
||||
HtmlUtils.removeElementByIdOrFail<HTMLDivElement>(this.getHtmlMessageId(messageId));
|
||||
}
|
||||
|
||||
private getHtmlMessageId(messageId: number) : string{
|
||||
private getHtmlMessageId(messageId: string) : string{
|
||||
return `message-${messageId}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue