07-10-2019, 03:08 PM
(This post was last modified: 07-10-2019, 03:47 PM by cprmlao@hotmail.com.)
Hi,
I have many iw forms, all inherited from a standard iwform(TIWFormStd).
I have a MasterTemplate html to all my IWForms.
I have my websocket server component in servercontroller module(I don´t know if this is the better place)
I need the websocket client available in all forms, because my app has a chat to users.
In that MasterTemplate, I have the next script code to connect to websocket server:
My problem is that when I open a new iwform, I allways release the old iwform. As the old form is released, the websocket connection in the frontend is destroyed as well and recreated when the new IWForm is active.
I´d like to know some suggestions about where I can put the websocket client code to avoid it.
Regards, Luiz
I have many iw forms, all inherited from a standard iwform(TIWFormStd).
I have a MasterTemplate html to all my IWForms.
I have my websocket server component in servercontroller module(I don´t know if this is the better place)
I need the websocket client available in all forms, because my app has a chat to users.
In that MasterTemplate, I have the next script code to connect to websocket server:
Code:
<script>
function wschat()
{
if (!ws || ws.state()!='open'){
ws = new sgcWebSocket('ws://127.0.0.1:5414/auth/url/admin/1234');
}
ws.on('open', function(evt){
console.log(ws.state())
});
ws.on('message', function(evt){
console.log(evt.message)
})
}
wschat()
</script>
My problem is that when I open a new iwform, I allways release the old iwform. As the old form is released, the websocket connection in the frontend is destroyed as well and recreated when the new IWForm is active.
I´d like to know some suggestions about where I can put the websocket client code to avoid it.
Regards, Luiz