})
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;
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;