From 4b882517bf2fc775f83566cd15fb166a8a94bcf1 Mon Sep 17 00:00:00 2001 From: AdrienHdz Date: Sun, 15 Oct 2023 23:41:34 -0400 Subject: [PATCH] chore: Handling session_id on frontend side --- frontend/src/app/messages/messages.component.ts | 1 + frontend/src/app/service/dataservice.service.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/messages/messages.component.ts b/frontend/src/app/messages/messages.component.ts index f11066a..48b17f7 100644 --- a/frontend/src/app/messages/messages.component.ts +++ b/frontend/src/app/messages/messages.component.ts @@ -50,6 +50,7 @@ export class MessagesComponent implements AfterViewInit { this.addServerMessage(response.script_response); this.setVideoSourceAndPlay(response.url_response); console.log(response) + this.dataService.currentSessionId = response.session_id; this.setFetchingStateDone(); }, error => { console.error('Error fetching server response:', error); diff --git a/frontend/src/app/service/dataservice.service.ts b/frontend/src/app/service/dataservice.service.ts index 70566f9..1fd3ae8 100644 --- a/frontend/src/app/service/dataservice.service.ts +++ b/frontend/src/app/service/dataservice.service.ts @@ -21,13 +21,25 @@ export class DataService { private _server_response = new ReplaySubject(1); public server_response: Observable = this._server_response.asObservable() + private _currentSessionId: string | null = null; + + get currentSessionId(): string | null { + return this._currentSessionId; + } + + set currentSessionId(sessionId: string | null) { + this._currentSessionId = sessionId; + } + constructor(private HttpClient: HttpClient) { } getMessageResponse(userMessage: string): Observable { console.log("Sending data to server"); this._fetchingStateMessage.next(FetchingServerState.FETCHING); - return this.HttpClient.post(this.api_server + '/get_response', { message: userMessage }); + return this.HttpClient.post(this.api_server + '/get_response', + { message: userMessage, + session_id: this.currentSessionId }); }