Skip to content

Commit

Permalink
Merge pull request #222 from basoro/mlite
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
basoro authored Oct 10, 2024
2 parents 57c9cc8 + cc7b949 commit 3b89a81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions themes/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
</script>
{loop: $mlite.header}{$value}{/loop}
{if: $mlite.websocket == 'ya'}
<script>
var URL_WEBSOCKET = "ws://<?php echo $_SERVER['HTTP_HOST'] ?>:3892";
</script>
<script src="{?=url(THEMES.'/admin/js/websocket.js?v='.$mlite.version)?}"></script>
{/if}
</head>
Expand Down
6 changes: 3 additions & 3 deletions themes/admin/js/websocket.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let URL_WEBSOCKET = "ws://localhost:3892";
let ws = new WebSocket(URL_WEBSOCKET);
// let URL_WEBSOCKET = "ws://localhost:3892";
var ws = new WebSocket(URL_WEBSOCKET);
var baseURL = mlite.url + '/' + mlite.admin;

ws.onmessage = function(response){
Expand All @@ -18,7 +18,7 @@ ws.onmessage = function(response){

ws.onclose = function(){
// Jika terputus dari websocket server, maka mencoba terhubung kembali.
let interval_reconnect_ws = setInterval(function(){
var interval_reconnect_ws = setInterval(function(){
if(ws.readyState != 0){
if(ws.readyState == 1){ // readyState = 1 (Open) , berarti sudah terhubung dengan websocket. Maka gak perlu interval lagi.
clearInterval(interval_reconnect_ws);
Expand Down

0 comments on commit 3b89a81

Please sign in to comment.