mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
Merge branch 'feature/websocket' of https://bitbucket.org/equilibriumito/gabinete-digital into feature/websocket
This commit is contained in:
+31
-20
@@ -17,7 +17,6 @@ import { File } from '@ionic-native/file/ngx';
|
||||
/* import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; */
|
||||
import { DocumentCounterService } from '../services/worker/document-counter.service';
|
||||
import { PermissionService } from '../services/worker/permission.service';
|
||||
import { Network } from '@ionic-native/network/ngx';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
@@ -29,7 +28,7 @@ import { Device } from '@capacitor/device';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { RocketChatClientService } from 'src/app/services/socket/rocket-chat-client.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -73,8 +72,6 @@ export class HomePage implements OnInit {
|
||||
status: string = "";
|
||||
audioName: string = "";
|
||||
|
||||
RocketChatClientService = RocketChatClientService
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
public modalCtrl: AlertController,
|
||||
@@ -95,25 +92,39 @@ export class HomePage implements OnInit {
|
||||
private processservice: ProcessesService,
|
||||
private screenOrientation: ScreenOrientation,
|
||||
private sqliteservice: SqliteService,
|
||||
private RouteService: RouteService) {
|
||||
private RouteService: RouteService,
|
||||
private RocketChatClientService: RocketChatClientService) {
|
||||
|
||||
this.RocketChatClientService.connect(()=>{
|
||||
|
||||
this.RocketChatClientService.login({
|
||||
username: 'paulo.pinto',
|
||||
email: 'paulo.pinto@gabinetedigital.local',
|
||||
password: 'tabteste@006'
|
||||
}).then((message)=>{
|
||||
console.log('rocket chat login successfully', message)
|
||||
this.RocketChatClientService.getRooms().then((rooms)=>{
|
||||
console.log('rooms', rooms)
|
||||
})
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
}).finally(()=>{
|
||||
this.RocketChatClientService.loadHistory('fsMwcNdufWvdnChj7ya9nF9cX2HizxxWAM', 10).then((message)=>{
|
||||
console.log('loadHistory', message)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
this.RocketChatClientService.receiveLiveMessageFromRoom(
|
||||
'fsMwcNdufWvdnChj7ya9nF9cX2HizxxWAM',
|
||||
this.constructor.name,
|
||||
(Chatmessage)=>{
|
||||
console.log('chat', Chatmessage)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
window['jj'] = ()=>{
|
||||
//send message // roomId // Message
|
||||
this.RocketChatClientService.send('fsMwcNdufWvdnChj7ya9nF9cX2HizxxWAM', 'Mensagem enviada programaticamente.'+ new Date().toISOString())
|
||||
}
|
||||
|
||||
// this.RocketChatClientService.send()
|
||||
/* this.webNotificationPopupService.askNotificationPermission() */
|
||||
|
||||
Reference in New Issue
Block a user