lien editor -> live editor

pull/12/head
Bastien OLLIER 11 months ago
parent 5505f9d3e7
commit 0990be2866

@ -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!);
@ -162,11 +166,14 @@ export class EditorComponent {
private router: Router,
private backendService: BackendService
) {
<<<<<<< HEAD
backendService.getResult().subscribe((msg) => {
if (msg.type === 'stdout' || msg.type === 'stderr') {
this.resultContent += msg.text;
}
})
=======
>>>>>>> 5f66c6e (lien editor -> live editor)
}
// Efface le contenu de l'éditeur
@ -175,7 +182,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}`]);
}

@ -16,8 +16,14 @@ export class BackendService {
constructor() {}
async createRoom() {
const reponse = await fetch(`${this.apiUrl}/live`, { method: 'POST' });
async createRoom(code: string) {
const reponse = await fetch(`${this.apiUrl}/live`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify( {code} )
});
return reponse.text();
}

Loading…
Cancel
Save