mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-25 21:39:21 +00:00
Ready to implement WebSocket
This commit is contained in:
parent
99aafe3799
commit
a027e96071
@ -79,6 +79,10 @@ ComunicWeb.common.system = {
|
|||||||
//Open specified page
|
//Open specified page
|
||||||
ComunicWeb.common.page.openPage(openPage);
|
ComunicWeb.common.page.openPage(openPage);
|
||||||
|
|
||||||
|
// Initialize Websocket if user is connect
|
||||||
|
if(signed_in())
|
||||||
|
UserWebSocket.Connect();
|
||||||
|
|
||||||
//End of init
|
//End of init
|
||||||
ComunicWeb.debug.logMessage("Application is ready !");
|
ComunicWeb.debug.logMessage("Application is ready !");
|
||||||
}
|
}
|
||||||
@ -91,6 +95,7 @@ ComunicWeb.common.system = {
|
|||||||
/**
|
/**
|
||||||
* Automaticaly refresh login state
|
* Automaticaly refresh login state
|
||||||
*/
|
*/
|
||||||
|
// TODO : remove when websockets are implemented
|
||||||
var autoRefresh = setInterval((function(){
|
var autoRefresh = setInterval((function(){
|
||||||
ComunicWeb.user.userLogin.refreshLoginState();
|
ComunicWeb.user.userLogin.refreshLoginState();
|
||||||
}), 25000);
|
}), 25000);
|
||||||
|
24
assets/js/common/ws.js
Normal file
24
assets/js/common/ws.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Main client websocket
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
class UserWebSocket {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to server
|
||||||
|
*/
|
||||||
|
static async Connect() {
|
||||||
|
await this.Disconnect();
|
||||||
|
|
||||||
|
console.log("Connect to websocket");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect from server
|
||||||
|
*/
|
||||||
|
static async Disconnect() {
|
||||||
|
console.log("Disconnect from websockt");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -176,6 +176,9 @@ ComunicWeb.user.userLogin = {
|
|||||||
|
|
||||||
//Save email address
|
//Save email address
|
||||||
ComunicWeb.components.mailCaching.set(usermail);
|
ComunicWeb.components.mailCaching.set(usermail);
|
||||||
|
|
||||||
|
// Initialize websocket
|
||||||
|
UserWebSocket.Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Perform next action if login failed
|
//Perform next action if login failed
|
||||||
@ -213,7 +216,10 @@ ComunicWeb.user.userLogin = {
|
|||||||
*
|
*
|
||||||
* @param {Function} afterLogout What to do once user is logged out
|
* @param {Function} afterLogout What to do once user is logged out
|
||||||
*/
|
*/
|
||||||
logoutUser: function(afterLogout){
|
logoutUser: async function(afterLogout){
|
||||||
|
|
||||||
|
await UserWebSocket.Disconnect();
|
||||||
|
|
||||||
//Prepare and make an API request
|
//Prepare and make an API request
|
||||||
var apiURI = "user/disconnectUSER";
|
var apiURI = "user/disconnectUSER";
|
||||||
var params = {};
|
var params = {};
|
||||||
|
@ -325,6 +325,7 @@ class Dev {
|
|||||||
"js/common/date.js",
|
"js/common/date.js",
|
||||||
"js/common/system.js",
|
"js/common/system.js",
|
||||||
array("path" => "js/common/songPlayer.js", "uglifyjs" => false),
|
array("path" => "js/common/songPlayer.js", "uglifyjs" => false),
|
||||||
|
array("path" => "js/common/ws.js", "uglifyjs" => false),
|
||||||
|
|
||||||
//Languages
|
//Languages
|
||||||
"js/langs/en.inc.js",
|
"js/langs/en.inc.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user