improve rocket-chat-cliente interface

This commit is contained in:
Peter Maquiran
2022-01-07 11:21:14 +01:00
parent 6e0b54c0cf
commit d951bf6cc1
7 changed files with 158 additions and 56 deletions
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { SocketInterfaceService } from './interface/socket-interface.service'
import { environment } from 'src/environments/environment';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
providedIn: 'root'
@@ -9,16 +10,25 @@ export class RocketChatClientService {
private SocketInterfaceService = new SocketInterfaceService()
constructor() {
const url = environment.apiChatUrl.replace('https','wss')
// this.SocketInterfaceService.connect(url);
constructor() {}
connect(url = 'wss://gabinetedigitalchat.dyndns.info/websocket') {
this.SocketInterfaceService.connect(url);
const connectMessage = {
msg: "connect",
version: "1",
support: ["1"]
}
this.SocketInterfaceService.send(connectMessage)
}
login(user) {
const loginRequest = {
msg: "method",
method: "login",
id: "42",
id: uuidv4(),
params: [
{
"user": { "username": user.username },
@@ -29,17 +39,31 @@ export class RocketChatClientService {
}
]
}
// this.SocketInterfaceService.send(loginRequest)
this.SocketInterfaceService.send(loginRequest)
}
logout(){ }
send(roomId, message, option) {}
send(roomId, message, option) {
var request = {
"msg": "method",
"method": "sendMessage",
"id": uuidv4(),
"params": [{
"_id": "message-id",
"rid": "room-id",
"msg": "Hello World!"
}]
}
this.SocketInterfaceService.send(request);
}
receive() {}
joinRoom(){}
deleteMessage() {}
createRoom() {}
}