CaptainCasa WebSockets

Viewed 87
getWorkpage().addLifecycleListener(new WorkpageDefaultLifecycleListener()
        {
            @Override
            public void reactOnDestroyed()
            {
                if (m_thread != null)
                    m_thread.i_threadStop = true;
                LongPollingMgr.remove(m_longPollingWebSocket);
            }
        });

this is called only when closing the application.

The event producing thread does not get affected if browser page is closed or refreshed. it keeps running.

How to deal with this ?

Update: The problem was, that i was lacking sessioncloser component in the jsp. It will call destroy() on the Dispatcher when the web page is refreshed or closed, which will call my reactOnDestroyed callback. It works on Workpage level and Outside level

2 Answers

Just to summarize:

The event was not called because the session was not closed. The browser does not tell the server "by itself" that is is closed/refreshed/.... The default behavior as consequence is: the sessions are timed out at server side (then the reactOnDestroyed is called! - but this takes some minutes to wait...)

By adding a component SESSIONCLOSER to the client dialog, the JavaScript processing will notify the serve when the page is closed/refreshed/... So in this scenario the session is closed immediately - and the event also is called immediately.

So, the problem was the not-closing of the session.

By the way: I was not right when saying that the "dummy workpage" on "ourside-level" was not processing the event correctly - it does. So you can register on any level to the current workpage and register a listener there: it will be notified on closing correctly.

Do you start the WebSocket connection from a Workpage-level (== dialog that opens up in the content part of the workplace) or is it something that you start from some outer function (== function which is in the surrounding of the workplace management?)

If "Workpage-level": it must be called! ;-)

If "Outside-level": here you can register in some pro dummy workpage listener, but this one is not processed. - So what to do: when closing the session, then Dispatcher-destroy() gets called. Please somehow register the closing of the WebSocket in this destroy.

Related