Skip to content

Commit

Permalink
chore: Handling session_id on frontend side
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienHdz committed Oct 16, 2023
1 parent 058ed21 commit 4b88251
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/src/app/messages/messages.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/app/service/dataservice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@ export class DataService {
private _server_response = new ReplaySubject<any>(1);
public server_response: Observable<any> = 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<any> {
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 });
}


Expand Down

0 comments on commit 4b88251

Please sign in to comment.