mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
add subscribe
This commit is contained in:
@@ -107,8 +107,16 @@ export class HomePage implements OnInit {
|
||||
}).then((message)=>{
|
||||
// alert('login')
|
||||
console.log('rocket chat login successfully', message)
|
||||
this.RocketChatClientService.getRooms().then((rooms)=>{
|
||||
this.RocketChatClientService.getRooms().then((rooms: any)=>{
|
||||
console.log('rooms', rooms)
|
||||
|
||||
rooms.result.update.forEach((room:any) => {
|
||||
console.log('room', room)
|
||||
this.RocketChatClientService.subscribe(room.lastMessage.rid).then((subscription)=>{
|
||||
console.log('subscription', subscription)
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
|
||||
@@ -128,19 +128,19 @@ class _RocketChatClientService {
|
||||
}
|
||||
|
||||
|
||||
subscribe() {
|
||||
subscribe(roomId : string) {
|
||||
const requestId = uuidv4()
|
||||
var subscribeRequest = {
|
||||
"msg": "sub",
|
||||
"id": requestId,
|
||||
"name": "stream-notify-room",
|
||||
"params":[
|
||||
"room-id/event",
|
||||
`${roomId}/event`,
|
||||
false
|
||||
]
|
||||
}
|
||||
|
||||
this.ws.send(subscribeRequest);
|
||||
this.ws.send(subscribeRequest);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.ws.registerCallback({type:'Onmessage', requestId, runOnces: true, funx:(message)=>{
|
||||
|
||||
Reference in New Issue
Block a user