Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advice about where put a code to websocket
#1
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:

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
Reply


Messages In This Thread
Advice about where put a code to websocket - by cprmlao@hotmail.com - 07-10-2019, 03:08 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)