B4J Question Detect websocket connection lost

Roycefer

Well-Known Member
Licensed User
Longtime User
If you are using b4j_ws.js, then open it up in Notepad or something and add this to the bottom, just before the last closing bracket:
B4X:
b4j_ws.onclose = function(event)
{
     b4j_runFunction("socketDisconnected", event);
};

And then in your webpage (the one that has <script src="b4j_ws.js"> in it), make sure to implement the "socketDisconnected" function. For example:
B4X:
function socketDisconnected(event)
{  
      alert("Websocket connection closed");
}
 
Upvote 0

Philip Prins

Active Member
Licensed User
Longtime User
If you are using b4j_ws.js, then open it up in Notepad or something and add this to the bottom, just before the last closing bracket:
B4X:
b4j_ws.onclose = function(event)
{
     b4j_runFunction("socketDisconnected", event);
};

And then in your webpage (the one that has <script src="b4j_ws.js"> in it), make sure to implement the "socketDisconnected" function. For example:
B4X:
function socketDisconnected(event)
{ 
      alert("Websocket connection closed");
}

Works great,thank you very much...
 
Upvote 0
Top