This commit is contained in:
tiago.kayaya
2021-05-18 09:37:23 +01:00
parent e00a8ebeab
commit e47920cdfc
3 changed files with 97 additions and 24 deletions
+48
View File
@@ -72,6 +72,16 @@ export class ChatPage implements OnInit {
@Output() getRoomInfo;
/*
Websockets variables
*/
SERVER_URL = 'wss://www.tabularium.pt/websocket';
ws:any;
/* Fim websockets variables*/
constructor(
private http:HttpClient,
private chatService: ChatService,
@@ -100,9 +110,47 @@ export class ChatPage implements OnInit {
})
console.log(this.roomId);
this.connect();
}
/* websocket functions */
connect() {
this.ws = new WebSocket(this.SERVER_URL, []);
console.log(this.ws);
/* this.ws.onmessage = handleMessageReceived;
this.ws.onerror = handleError; */
}
handleMessageReceived(data) {
// Simply call logMessage(), passing the received data.
/* logMessage(data.data); */
}
handleConnected(data) {
// Create a log message which explains what has happened and includes
// the url we have connected too.
var logMsg = 'Connected to server: ' + data.target.url;
// Add the message to the log.
/* logMessage(logMsg) */
}
handleError(err) {
// Print the error to the console so we can debug it.
console.log("Error: ", err);
}
logMessage(msg) {
// $apply() ensures that the elements on the page are updated
// with the new message.
/* $scope.$apply(function() { */
//Append out new message to our message log. The \n means new line.
/* $scope.messageLog = $scope.messageLog + msg + "\n"; */
// Update the scrolling (defined below).
/*updateScrolling();*/
/* S */
}
/* Fim websockets functions */
closeAllDesktopComponents() {
this.showMessages=false;
this.showContacts=false;