This commit is contained in:
tiago.kayaya
2022-01-12 09:29:48 +01:00
parent f90773459c
commit d0b1401d42
7 changed files with 72 additions and 19 deletions
+30 -3
View File
@@ -21,7 +21,7 @@ export class ChatService {
X_Auth_Token:any;
//SERVER_URL = 'wss://www.tabularium.pt/websocket';
public messages: Subject<any>;
//public messages: Subject<any>;
loggedUserChat:any;
bindOnMessage: any;
@@ -44,15 +44,42 @@ export class ChatService {
console.log("CHAT SERVICE");
this.messages = <Subject<any>>this.wsService
wsService.messages = <Subject<any>>this.wsService
.connect(environment.apiWsChatUrl)
.map((response: MessageEvent): any => {
let data = JSON.parse(response.data);
console.log(data);
if(data.msg == 'ping'){
wsService.messages.next({msg:'pong'});
if(!this.authService.isWsAuthenticated){
//this.authService.loginWsChat();
let msg = {
"msg": "method",
"method": "login",
"id":"1",
"params":[
{
"user": { "username": "paulo.pinto" },
"password": "tabteste@006"
}
]
}
wsService.messages.next(msg);
console.log('Authenticate');
this.authService.isWsAuthenticated = true;
}
//this.authService.loginWsChat();
}
if(data.id == '1'){
this.authService.wsValidatedUserChat = data;
}
return (JSON.stringify(data));
});
console.log(this.messages);
console.log(wsService.messages);
}