[
https://issues.apache.org/jira/browse/WICKET-6762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17067530#comment-17067530
]
Thomas Heigl commented on WICKET-6762:
--------------------------------------
Unrelated. When I tried to verify my change with the WebSocket demo page, I get
an exception on the current master branch:
{code:java}
ERROR - DefaultExceptionMapper - Unexpected error occurredERROR -
DefaultExceptionMapper - Unexpected error
occurredorg.apache.wicket.markup.MarkupNotFoundException: Failed to find markup
file associated. InspectorDebugPanel: [InspectorDebugPanel [Component id =
contrib]] at
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:99)
at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:503) at
org.apache.wicket.Component.getMarkup(Component.java:750) at
org.apache.wicket.Component.getMarkupTag(Component.java:1394) at
org.apache.wicket.markup.html.link.Link.renderHead(Link.java:391) at
org.apache.wicket.Component.internalRenderHead(Component.java:2642) at
org.apache.wicket.markup.renderStrategy.ChildFirstHeaderRenderStrategy$1.component(ChildFirstHeaderRenderStrategy.java:85)
{code}
> Support manual initialization of websocket connections
> ------------------------------------------------------
>
> Key: WICKET-6762
> URL: https://issues.apache.org/jira/browse/WICKET-6762
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-native-websocket
> Affects Versions: 8.7.0
> Reporter: Thomas Heigl
> Assignee: Martin Tzvetanov Grigorov
> Priority: Major
>
> {{BaseWebSocketBehavior}} currently calls
> {{Wicket.WebSocket.createDefaultConnection()}} on DOM ready. I would like to
> be able to delay connection creation and trigger it myself.
> Desktop users of our application tend to open quite a number of tabs from
> search result pages and other lists and Wicket creates a new websocket
> connection for all tabs opened in the background.
> I implemented a solution that uses the Page Visibility API to open and close
> websocket connections when a page becomes visible or hidden. Since I
> currently cannot disable the default connection, I'm closing the connection
> immediately:
> {code:java}
> if (document.hidden) {
> if (Wicket.WebSocket.INSTANCE) {
> Wicket.WebSocket.INSTANCE.close();
> }
> }
> var connectFunction = function () {
> if (document.hidden) {
> if (Wicket.WebSocket.INSTANCE) {
> Wicket.WebSocket.INSTANCE.close();
> }
> } else {
> if (!Wicket.WebSocket.INSTANCE) {
> Wicket.WebSocket.createDefaultConnection();
> }
> }
> };
> document.addEventListener('visibilitychange', connectFunction, false);
> {code}
> This works, but most browsers log an error like this:
> {code:java}
> Connection failed. WebSocket is closed before the connection is established.
> {code}
> A configuration option to disable automatic connection creation would solve
> this.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)