Skip to content

Commit 5b32225

Browse files
committed
SVY-9447 Endpoint was closed message in logs
1 parent 3ebbd4f commit 5b32225

File tree

4 files changed

+22
-42
lines changed

4 files changed

+22
-42
lines changed

servoy_ngclient/src/com/servoy/j2db/server/ngclient/INGClientWebsocketSession.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
2121

2222
import org.sablo.IChangeListener;
2323
import org.sablo.websocket.IWebsocketSession;
24-
import org.sablo.websocket.IWindow;
25-
import org.sablo.websocket.utils.ObjectReference;
2624

2725
import com.servoy.j2db.persistence.Solution;
2826

@@ -48,5 +46,5 @@ public interface INGClientWebsocketSession extends IWebsocketSession, IChangeLis
4846
@Override
4947
Collection<INGClientWindow> getWindows();
5048

51-
Collection<ObjectReference< ? extends IWindow>> getWindowsRefs();
49+
long getLastAccessed();
5250
}

servoy_ngclient/src/com/servoy/j2db/server/ngclient/NGClient.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.rmi.RemoteException;
88
import java.sql.Types;
99
import java.text.SimpleDateFormat;
10-
import java.util.Collection;
1110
import java.util.Date;
1211
import java.util.HashMap;
1312
import java.util.List;
@@ -32,9 +31,7 @@
3231
import org.sablo.specification.WebServiceSpecProvider;
3332
import org.sablo.websocket.CurrentWindow;
3433
import org.sablo.websocket.IServerService;
35-
import org.sablo.websocket.IWindow;
3634
import org.sablo.websocket.WebsocketSessionManager;
37-
import org.sablo.websocket.utils.ObjectReference;
3835

3936
import com.servoy.base.persistence.constants.IValueListConstants;
4037
import com.servoy.j2db.ApplicationException;
@@ -1277,9 +1274,9 @@ public void changesWillBeSend()
12771274
*/
12781275
public String getStatusLine()
12791276
{
1280-
Collection<ObjectReference< ? extends IWindow>> refs = getWebsocketSession().getWindowsRefs();
1277+
long lastAccessed = getWebsocketSession().getLastAccessed();
12811278

1282-
if (refs.size() == 0)
1279+
if (lastAccessed == Long.MIN_VALUE)
12831280
{
12841281
// this should normally not happen
12851282
return "No websockets";
@@ -1292,13 +1289,6 @@ public String getStatusLine()
12921289
return "Websocket connected, last ping time: " + new SimpleDateFormat("EEE HH:mm:ss").format(new Date(lastPingTime));
12931290
}
12941291

1295-
// all windows are inactive get the last accessed.
1296-
long lastAccessed = Long.MIN_VALUE;
1297-
for (ObjectReference< ? extends IWindow> ref : refs)
1298-
{
1299-
lastAccessed = Math.max(lastAccessed, ref.getLastAccessed());
1300-
}
1301-
13021292
return "Websockets disconnected since " + new SimpleDateFormat("EEE HH:mm:ss").format(new Date(lastAccessed));
13031293
}
13041294

servoy_ngclient/src/com/servoy/j2db/server/ngclient/NGClientWebsocketSession.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
3434
import org.sablo.websocket.CurrentWindow;
3535
import org.sablo.websocket.IClientService;
3636
import org.sablo.websocket.IServerService;
37+
import org.sablo.websocket.IWebsocketSession;
3738
import org.sablo.websocket.IWindow;
3839
import org.sablo.websocket.WebsocketSessionManager;
39-
import org.sablo.websocket.utils.ObjectReference;
4040

4141
import com.servoy.j2db.FlattenedSolution;
4242
import com.servoy.j2db.J2DBGlobals;
@@ -88,9 +88,9 @@ public NGClient getClient()
8888
}
8989

9090
@Override
91-
public INGClientWindow createWindow(String windowName)
91+
public INGClientWindow createWindow(IWebsocketSession session, String windowUuid, String windowName)
9292
{
93-
return new NGClientWindow(this, windowName);
93+
return new NGClientWindow(this, windowUuid, windowName);
9494
}
9595

9696
@SuppressWarnings("unchecked")
@@ -100,12 +100,6 @@ public Collection<INGClientWindow> getWindows()
100100
return (Collection<INGClientWindow>)super.getWindows();
101101
}
102102

103-
@Override
104-
public Collection<ObjectReference< ? extends IWindow>> getWindowsRefs()
105-
{
106-
return super.getWindowsRefs();
107-
}
108-
109103
@Override
110104
public boolean isValid()
111105
{
@@ -337,9 +331,9 @@ public static void sendInternalError(Exception e)
337331
}
338332

339333
@Override
340-
public void invalidateWindow(IWindow window)
334+
public void updateLastAccessed(IWindow window)
341335
{
342-
super.invalidateWindow(window);
336+
super.updateLastAccessed(window);
343337

344338
// check for window activity each time a window is closed, after the timeout period
345339
ApplicationServerRegistry.get().getExecutor().schedule(new Runnable()

servoy_ngclient/src/com/servoy/j2db/server/ngclient/NGClientWindow.java

+14-16
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
5454
public class NGClientWindow extends BaseWindow implements INGClientWindow
5555
{
5656

57-
private final INGClientWebsocketSession websocketSession;
58-
5957
/**
6058
* @param websocketSession
59+
* @param windowUuid
6160
* @param windowName
6261
*/
63-
public NGClientWindow(INGClientWebsocketSession websocketSession, String windowName)
62+
public NGClientWindow(INGClientWebsocketSession websocketSession, String windowUuid, String windowName)
6463
{
65-
super(windowName);
66-
this.websocketSession = websocketSession;
64+
super(websocketSession, windowUuid, windowName);
6765
}
6866

6967
public static INGClientWindow getCurrentWindow()
@@ -91,13 +89,13 @@ public INGApplication getClient()
9189
@Override
9290
public Container getForm(String formName)
9391
{
94-
return (Container)websocketSession.getClient().getFormManager().getForm(formName).getFormUI();
92+
return (Container)getSession().getClient().getFormManager().getForm(formName).getFormUI();
9593
}
9694

9795
@Override
9896
public void sendChanges() throws IOException
9997
{
100-
if (websocketSession.getClient() != null) websocketSession.getClient().changesWillBeSend();
98+
if (getSession().getClient() != null) getSession().getClient().changesWillBeSend();
10199
super.sendChanges();
102100
}
103101

@@ -111,7 +109,7 @@ protected Object invokeApi(WebComponent receiver, WebObjectApiDefinition apiFunc
111109
boolean delayedCall = isDelayedApiCall(receiver, apiFunction);
112110
if (!delayedCall)
113111
{
114-
IWebFormController form = websocketSession.getClient().getFormManager().getForm(receiver.findParent(IWebFormUI.class).getName());
112+
IWebFormController form = getSession().getClient().getFormManager().getForm(receiver.findParent(IWebFormUI.class).getName());
115113
touchForm(form.getForm(), form.getName(), false);
116114
}
117115
if (receiver instanceof WebFormComponent && ((WebFormComponent)receiver).getComponentContext() != null)
@@ -162,7 +160,7 @@ public void touchForm(Form form, String realInstanceName, boolean async)
162160
String currentWindowName = getCurrentWindow().getName();
163161
if (currentWindowName == null)
164162
{
165-
currentWindowName = websocketSession.getClient().getRuntimeWindowManager().getMainApplicationWindow().getName();
163+
currentWindowName = getSession().getClient().getRuntimeWindowManager().getMainApplicationWindow().getName();
166164
}
167165
formUI.setParentWindowName(currentWindowName);
168166
}
@@ -185,7 +183,7 @@ public void touchForm(Form form, String realInstanceName, boolean async)
185183
{
186184
// this means a previous async touchForm already sent URL and JS code (updateController) to client, but the client form was not yet loaded (directives, scopes....)
187185
// so probably a tabpanel or component that asked for it changed it's mind and no longer showed it; make sure it will show before waiting!
188-
websocketSession.getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("requireFormLoaded",
186+
getSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("requireFormLoaded",
189187
new Object[] { formName });
190188
}
191189
Debug.debug("touchForm(" + async + ") - will suspend: " + form.getName());
@@ -200,7 +198,7 @@ public void touchForm(Form form, String realInstanceName, boolean async)
200198
}
201199
try
202200
{
203-
websocketSession.getEventDispatcher().suspend(formUrl, IWebsocketEndpoint.EVENT_LEVEL_SYNC_API_CALL, EventDispatcher.CONFIGURED_TIMEOUT);
201+
getSession().getEventDispatcher().suspend(formUrl, IWebsocketEndpoint.EVENT_LEVEL_SYNC_API_CALL, EventDispatcher.CONFIGURED_TIMEOUT);
204202
}
205203
catch (CancellationException e)
206204
{
@@ -243,11 +241,11 @@ protected void updateController(Form form, final String realFormName, final bool
243241
@Override
244242
public void run()
245243
{
246-
if (websocketSession.getClient().isEventDispatchThread() && forceLoad)
244+
if (getSession().getClient().isEventDispatchThread() && forceLoad)
247245
{
248246
try
249247
{
250-
websocketSession.getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeServiceCall("updateController",
248+
getSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeServiceCall("updateController",
251249
new Object[] { realFormName, jsTemplate, realUrl, Boolean.valueOf(forceLoad), htmlTemplate });
252250
}
253251
catch (IOException e)
@@ -257,7 +255,7 @@ public void run()
257255
}
258256
else
259257
{
260-
websocketSession.getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("updateController",
258+
getSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("updateController",
261259
new Object[] { realFormName, jsTemplate, realUrl, Boolean.valueOf(forceLoad), htmlTemplate });
262260
}
263261
}
@@ -289,7 +287,7 @@ protected String dropSessionIdFrom(String realNewURL)
289287

290288
protected Pair<String, Boolean> getRealFormURLAndSeeIfItIsACopy(Form form, String realFormName, boolean addSessionID)
291289
{
292-
FlattenedSolution fs = websocketSession.getClient().getFlattenedSolution();
290+
FlattenedSolution fs = getSession().getClient().getFlattenedSolution();
293291
Solution sc = fs.getSolutionCopy(false);
294292
String realUrl = getDefaultFormURLStart(form, realFormName);
295293
boolean copy = false;
@@ -334,7 +332,7 @@ protected String getDefaultFormURLStart(Form form, String name)
334332

335333
public void destroyForm(String name)
336334
{
337-
websocketSession.getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("destroyController", new Object[] { name });
335+
getSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("destroyController", new Object[] { name });
338336
// also remove it from the endpoint as a form that is on the client.
339337
getEndpoint().formDestroyed(name);
340338
}

0 commit comments

Comments
 (0)