mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
connect to socket server
This commit is contained in:
@@ -27,7 +27,8 @@ import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -90,7 +91,8 @@ export class HomePage implements OnInit {
|
||||
private processservice: ProcessesService,
|
||||
private screenOrientation: ScreenOrientation,
|
||||
private sqliteservice: SqliteService,
|
||||
private RouteService: RouteService) {
|
||||
private RouteService: RouteService,
|
||||
private RocketChatClientService: RocketChatClientService) {
|
||||
|
||||
/* this.webNotificationPopupService.askNotificationPermission() */
|
||||
|
||||
@@ -235,3 +237,46 @@ 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