mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
rocket chat service
This commit is contained in:
+67
-65
@@ -73,6 +73,9 @@ export class HomePage implements OnInit {
|
||||
|
||||
status: string = "";
|
||||
audioName: string = "";
|
||||
|
||||
RocketChatClientService = RocketChatClientService
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
public modalCtrl: AlertController,
|
||||
@@ -93,89 +96,88 @@ export class HomePage implements OnInit {
|
||||
private processservice: ProcessesService,
|
||||
private screenOrientation: ScreenOrientation,
|
||||
private sqliteservice: SqliteService,
|
||||
private RouteService: RouteService,
|
||||
private RocketChatClientService: RocketChatClientService) {
|
||||
private RouteService: RouteService) {
|
||||
|
||||
// this.RocketChatClientService.connect()
|
||||
// this.RocketChatClientService.login({
|
||||
// username: 'paulo.pinto@gabinetedigital.local',
|
||||
// password: 'tabteste@006'
|
||||
// })
|
||||
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 = ()=> {
|
||||
// const url = 'wss://gabinetedigitalchat.dyndns.info/websocket'
|
||||
// const socket = new WebSocket(url);
|
||||
// socket.onopen = ()=> {
|
||||
|
||||
console.log('============================ welcome to rocket chat =========================================');
|
||||
// console.log('============================ welcome to rocket chat =========================================');
|
||||
|
||||
const connectRequest = {
|
||||
msg: "connect",
|
||||
version: "1",
|
||||
support: ["1", "pre2", "pre1"]
|
||||
}
|
||||
// const connectRequest = {
|
||||
// msg: "connect",
|
||||
// version: "1",
|
||||
// support: ["1", "pre2", "pre1"]
|
||||
// }
|
||||
|
||||
// ======================= connect
|
||||
socket.send(JSON.stringify(connectRequest ))
|
||||
};
|
||||
// // ======================= connect
|
||||
// socket.send(JSON.stringify(connectRequest ))
|
||||
// };
|
||||
|
||||
socket.onmessage = (event: any)=> {
|
||||
// socket.onmessage = (event: any)=> {
|
||||
|
||||
console.log('event.data', JSON.parse(event.data))
|
||||
// console.log('event.data', JSON.parse(event.data))
|
||||
|
||||
const data = JSON.parse(event.data)
|
||||
// const data = JSON.parse(event.data)
|
||||
|
||||
if(event.data=='{"msg":"ping"}') {
|
||||
socket.send('{"msg":"pong"}')
|
||||
// if(event.data=='{"msg":"ping"}') {
|
||||
// socket.send('{"msg":"pong"}')
|
||||
|
||||
const loginRequest = {
|
||||
msg: "method",
|
||||
method: "login",
|
||||
id: uuidv4(),
|
||||
params: [
|
||||
{
|
||||
"user": {
|
||||
"username": "paulo.pinto"
|
||||
},
|
||||
"password": "tabteste@006"
|
||||
}
|
||||
]
|
||||
}
|
||||
// const loginRequest = {
|
||||
// msg: "method",
|
||||
// method: "login",
|
||||
// id: uuidv4(),
|
||||
// params: [
|
||||
// {
|
||||
// "user": {
|
||||
// "username": "paulo.pinto"
|
||||
// },
|
||||
// "password": "tabteste@006"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
|
||||
// ======================== login
|
||||
socket.send(JSON.stringify(loginRequest))
|
||||
}
|
||||
// // ======================== login
|
||||
// socket.send(JSON.stringify(loginRequest))
|
||||
// }
|
||||
|
||||
// login successfully
|
||||
if(data.result) {
|
||||
if(data.result.token) {
|
||||
console.log('login successfully')
|
||||
// // login successfully
|
||||
// if(data.result) {
|
||||
// if(data.result.token) {
|
||||
// console.log('login successfully')
|
||||
|
||||
const requestId = uuidv4()
|
||||
// const requestId = uuidv4()
|
||||
|
||||
var requestMessage = {
|
||||
msg: "method",
|
||||
method: "sendMessage",
|
||||
id: requestId,
|
||||
params: [{
|
||||
_id: "message-id" || uuidv4(),
|
||||
rid: "room-id" || 444,
|
||||
msg: "Hello World!"
|
||||
}]
|
||||
}
|
||||
// var requestMessage = {
|
||||
// msg: "method",
|
||||
// method: "sendMessage",
|
||||
// id: requestId,
|
||||
// params: [{
|
||||
// _id: "message-id" || uuidv4(),
|
||||
// rid: "room-id" || 444,
|
||||
// msg: "Hello World!"
|
||||
// }]
|
||||
// }
|
||||
|
||||
// socket.send(JSON.stringify(requestMessage ))
|
||||
// // socket.send(JSON.stringify(requestMessage ))
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
socket.onclose = (event: any)=> {
|
||||
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
};
|
||||
// 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}`);
|
||||
};
|
||||
// socket.onerror =(event: any)=> {
|
||||
// console.log(`[error] ${event.message}`);
|
||||
// };
|
||||
|
||||
|
||||
// this.RocketChatClientService.send()
|
||||
|
||||
Reference in New Issue
Block a user