This commit is contained in:
Peter Maquiran
2022-01-10 13:31:15 +01:00
parent d4470e0b80
commit b82239741b
6 changed files with 57 additions and 4 deletions
+2 -2
View File
@@ -108,10 +108,10 @@ export class HomePage implements OnInit {
// alert('login')
console.log('rocket chat login successfully', message)
this.RocketChatClientService.getRooms().then((rooms: any)=>{
console.log('rooms', rooms)
// console.log('rooms', rooms)
rooms.result.update.forEach((room:any) => {
console.log('room', room)
// console.log('room', room)
this.RocketChatClientService.subscribe(room.lastMessage.rid).then((subscription)=>{
console.log('subscription', subscription)
})
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ChatService } from './chat.service';
describe('ChatService', () => {
let service: ChatService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ChatService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+9
View File
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ChatService {
constructor() { }
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { RoomService } from './room.service';
describe('RoomService', () => {
let service: RoomService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(RoomService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+9
View File
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class RoomService {
constructor() { }
}
@@ -2,6 +2,9 @@ import { Injectable } from '@angular/core';
import { v4 as uuidv4 } from 'uuid'
import { wsCallbacksParams, msgQueue } from 'src/app/models/rochet-chat-cliente-service'
/**
* Use this class to interact with rocketchat realtime API
*/
class _RocketChatClientService {
private hasPing = false
@@ -102,7 +105,7 @@ class _RocketChatClientService {
}
logout(){}
logout() {}
send(roomId, message) {
@@ -182,7 +185,7 @@ class _RocketChatClientService {
return new Promise((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', requestId, runOnces: true, funx:(message)=>{
if(message.result.id == requestId) { // same request send
if(message.msg == 'ready' || message.subs[0] == requestId) { // same request send
resolve(message)
}
}})