|
|
|
@ -140,6 +140,10 @@ export class EditorComponent {
|
|
|
|
|
private client: WebSocket | undefined;
|
|
|
|
|
@Input()
|
|
|
|
|
set idRoom(idRoom: string) {
|
|
|
|
|
if (idRoom === undefined) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.client = new WebSocket(`ws://127.0.0.1:3000/live/${idRoom}`);
|
|
|
|
|
this.client.addEventListener('open', async () => {
|
|
|
|
|
let conn = new Connection(this.client!);
|
|
|
|
@ -166,7 +170,7 @@ export class EditorComponent {
|
|
|
|
|
if (msg.type === 'stdout' || msg.type === 'stderr') {
|
|
|
|
|
this.resultContent += msg.text;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Efface le contenu de l'éditeur
|
|
|
|
@ -175,7 +179,7 @@ export class EditorComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onCreateRoomButtonClicked() {
|
|
|
|
|
const idRoom = await this.backendService.createRoom();
|
|
|
|
|
const idRoom = await this.backendService.createRoom(this.editorContent);
|
|
|
|
|
await this.router.navigate([`./editor-live/${idRoom}`]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -183,10 +187,7 @@ export class EditorComponent {
|
|
|
|
|
// Le code à exécuter est le contenu de l'éditeur
|
|
|
|
|
const codeToExecute = this.editorContent;
|
|
|
|
|
|
|
|
|
|
this.backendService.executeCode(
|
|
|
|
|
codeToExecute,
|
|
|
|
|
this.selectedLanguage.name
|
|
|
|
|
);
|
|
|
|
|
this.backendService.executeCode(codeToExecute, this.selectedLanguage.name);
|
|
|
|
|
|
|
|
|
|
this.resultContent = '';
|
|
|
|
|
}
|
|
|
|
|