lien editor -> live editor
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is failing Details

Bastien OLLIER 11 months ago
parent 09b0e1b2ee
commit 5f66c6e534

@ -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!);
@ -161,7 +165,8 @@ export class EditorComponent {
constructor(
private router: Router,
private backendService: BackendService
) {}
) {
}
// Efface le contenu de l'éditeur
clear(): void {
@ -169,7 +174,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