blob: 804847669abdee1163e87e2a12e69d739168e368 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { Component } from '@angular/core'
import { Observable } from 'rxjs'
import { MessagingService } from './messaging.service'
import { ChatMessage } from './chat-message.model'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
userId: string = ''
chatRoomId: string
messages$: Observable<ChatMessage[]>
messageBuff: string
constructor(private messaging: MessagingService) {}
ngOnInit() {
this.messaging.init()
}
sendMessage() {
this.messaging.sendMessage(this.userId, this.chatRoomId, this.messageBuff)
}
async makeChatRoom() {
this.chatRoomId = await this.messaging.makeChatRoom(this.userId)
this.messages$ = this.messaging.getChatRoom(this.chatRoomId)
}
}
|