mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
improve rocket-chat-cliente interface
This commit is contained in:
+82
-42
@@ -29,6 +29,8 @@ 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 { RealTimeAPI } from "rocket.chat.realtime.api.rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -94,6 +96,86 @@ export class HomePage implements OnInit {
|
||||
private RouteService: RouteService,
|
||||
private RocketChatClientService: RocketChatClientService) {
|
||||
|
||||
// this.RocketChatClientService.connect()
|
||||
// this.RocketChatClientService.login({
|
||||
// username: 'paulo.pinto@gabinetedigital.local',
|
||||
// password: 'tabteste@006'
|
||||
// })
|
||||
|
||||
|
||||
|
||||
// const url = 'wss://gabinetedigitalchat.dyndns.info/websocket'
|
||||
// const socket = new WebSocket(url);
|
||||
|
||||
|
||||
// socket.onopen = ()=> {
|
||||
|
||||
// console.log('============================ welcome to rocket chat =========================================');
|
||||
|
||||
// const connectMessage = {
|
||||
// msg: "connect",
|
||||
// version: "1",
|
||||
// support: ["1"]
|
||||
// }
|
||||
|
||||
// socket.send(JSON.stringify(connectMessage))
|
||||
|
||||
// const loginRequest = {
|
||||
// msg: "method",
|
||||
// method: "login",
|
||||
// id: uuidv4(),
|
||||
// params: [
|
||||
// {
|
||||
// "user": {
|
||||
// "email": 'paulo.pinto@gabinetedigital.local'
|
||||
// },
|
||||
// "password": {
|
||||
// "digest": 'tabteste@006',
|
||||
// "algorithm":"sha-256"
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
|
||||
// // temp login
|
||||
// socket.send(JSON.stringify(loginRequest))
|
||||
// };
|
||||
|
||||
// socket.onmessage = (event: any)=> {
|
||||
// // console.log('rocket chat message', event)
|
||||
// console.log('event.data', JSON.parse(event.data))
|
||||
// };
|
||||
|
||||
// socket.onclose = (event: any)=> {
|
||||
// console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
// };
|
||||
|
||||
// socket.onerror =(event: any)=> {
|
||||
// console.log(`[error] ${event.message}`);
|
||||
// };
|
||||
|
||||
|
||||
// const realTimeAPI = new RealTimeAPI("wss://gabinetedigitalchat.dyndns.info/websocket");
|
||||
// realTimeAPI.keepAlive().subscribe();
|
||||
// const auth = realTimeAPI.login('tiago.kayaya@gabinetedigital.local', 'tabteste@006');
|
||||
|
||||
// //Subscribe to messages and errors
|
||||
// auth.subscribe(
|
||||
// (data) => console.log('socket data', data),
|
||||
// (err) => console.log('socket err', err),
|
||||
// () => console.log('completed')
|
||||
// );
|
||||
|
||||
// // Subscribe to a specific channel, identified by roomId
|
||||
// realTimeAPI.sendMessage({
|
||||
// msg: 'sub',
|
||||
// id: '<a unique Id for subscription>',
|
||||
// name: 'stream-room-messages',
|
||||
// params: ['44', false],
|
||||
// });
|
||||
|
||||
// this.RocketChatClientService.send()
|
||||
|
||||
/* this.webNotificationPopupService.askNotificationPermission() */
|
||||
|
||||
this.router.events.subscribe((val) => {
|
||||
@@ -238,45 +320,3 @@ export class HomePage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const url = 'wss://gabinetedigitalchat.dyndns.info/websocket'
|
||||
const socket = new WebSocket(url);
|
||||
|
||||
|
||||
socket.onopen = ()=> {
|
||||
|
||||
console.log('============================ welcome to rocket chat =========================================');
|
||||
|
||||
|
||||
const loginRequest = {
|
||||
msg: "method",
|
||||
method: "login",
|
||||
id: "42",
|
||||
params: [
|
||||
{
|
||||
"user": { "username": 'paulo.pinto@gabinetedigital.local' },
|
||||
"password": {
|
||||
"digest": 'tabteste@006',
|
||||
"algorithm":"sha-256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// temp login
|
||||
socket.send(JSON.stringify(loginRequest))
|
||||
};
|
||||
|
||||
socket.onmessage = (event: any)=> {
|
||||
console.log('rocket chat message', event)
|
||||
console.log('event.data', JSON.parse(event.data))
|
||||
};
|
||||
|
||||
socket.onclose = (event: any)=> {
|
||||
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
};
|
||||
|
||||
socket.onerror =(event: any)=> {
|
||||
console.log(`[error] ${event.message}`);
|
||||
};
|
||||
Reference in New Issue
Block a user