mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
save
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user