refactor: Adjusted the chatroom-service to the changed URI's
authorKai Moritz <kai@juplo.de>
Sat, 14 Jan 2023 19:26:57 +0000 (20:26 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 14 Jan 2023 19:26:57 +0000 (20:26 +0100)
src/app/chatroom.service.ts

index 74bda94..1099c5e 100644 (file)
@@ -11,9 +11,7 @@ export const SSE_RECONNECT_UPPER_LIMIT = 64;
 })
 export class ChatroomService {
 
-  private uriList = 'http://localhost:8080/list';
-  private uriGet = 'http://localhost:8080/get/';
-  private uriListen = 'http://localhost:8080/listen/';
+  private backendUri = 'http://localhost:8080/';
 
   private channelUri: string = 'UNKNOWN';
   private eventSource?: EventSource;
@@ -24,15 +22,15 @@ export class ChatroomService {
   constructor(private http: HttpClient) { }
 
   getChatrooms(): Observable<Chatroom[]> {
-    return this.http.get<Chatroom[]>(this.uriList);
+    return this.http.get<Chatroom[]>(this.backendUri + 'list');
   }
 
   getChatroom(id: String): Observable<Chatroom> {
-    return this.http.get<Chatroom>(this.uriGet + id);
+    return this.http.get<Chatroom>(this.backendUri + id);
   }
 
   listen(id: String): Observable<Message> {
-    this.channelUri = this.uriListen + id;
+    this.channelUri = this.backendUri + id + '/listen';
     this.openChannel();
     let observable = new Observable<Message>((observer) => {
       this.channel = observer;