You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mashleyttu <ma...@gmail.com> on 2015/06/09 23:52:53 UTC

Atmosphere - Reconnect after Disconnect

Hi All, I asked an Atmosphere question a few days ago and have another one.

We are adding Atmosphere support to our application, and have added a
ResourceRegistrationListener to the EventBus so we can track and push
messages to users who request certain files. These files are generated on
the fly, and we don't want the user to have to wait for them to be created.

When the file has been created, we use the EventBus to push a success
message to the client who requested the file. The issue is the message has a
window.location.href = '/path/to/file.pdf' which is causing the page to
disconnect and the resourceUnregistered event to fire. This is causing
problems for future download request.

After the push message, I'm trying to have the client reconnect to the
server. I'm currently doing something like this:

public void reconnect(AjaxRequestTarget target, WebPage page) throws
JSONException{
		JSONObject options = bus.getParameters().toJSON();
		List<AtmosphereBehavior> lstAtmoBehaviors =
page.getBehaviors(AtmosphereBehavior.class);
		if(CollectionUtils.isNotEmpty(lstAtmoBehaviors)){
			options.put("url", page.urlFor(lstAtmoBehaviors.get(0),
IResourceListener.INTERFACE, new PageParameters()).toString());
		}
		//wait a quarter of a second for the download to fire before reconnecting
		target.appendJavaScript("setTimeout(function(){jQuery('#" +
page.getMarkupId() + "').wicketAtmosphere("+options.toString()+");},250);");
	}


This generates the same connection ajax call that the AtmosphereBehavior
renderHead method method generates. I've verified it calls the EventBus
resourceRegistered method. The uuid is unfortunately blank though.

Manually hitting the browser refresh button re-registers the page with the
uuid. 

Is there a fancy Wicket Atmosphere method to say "reconnect"? Or how do I
get Wicket to generate a UUID? Or a setting that says "reconnect"
automatically?

THanks

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Atmosphere-Reconnect-after-Disconnect-tp4671118.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Atmosphere - Reconnect after Disconnect

Posted by mashleyttu <ma...@gmail.com>.
Always great help out of this group! Invisible iFrame did the trick.
window.open caused popup warnings. The easiest solution is usually the best.

Thanks again! Matt

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Atmosphere-Reconnect-after-Disconnect-tp4671118p4671130.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Atmosphere - Reconnect after Disconnect

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Wed, Jun 10, 2015 at 12:52 AM, mashleyttu <ma...@gmail.com> wrote:

> Hi All, I asked an Atmosphere question a few days ago and have another one.
>
> We are adding Atmosphere support to our application, and have added a
> ResourceRegistrationListener to the EventBus so we can track and push
> messages to users who request certain files. These files are generated on
> the fly, and we don't want the user to have to wait for them to be created.
>
> When the file has been created, we use the EventBus to push a success
> message to the client who requested the file. The issue is the message has
> a
> window.location.href = '/path/to/file.pdf' which is causing the page to
>

Have you tried with a custom iframe? I.e. create a temporary iframe and set
its src to '/path/to/file.pdf'.
Or with window.open(url)

These approaches will leave the current page loaded.


> disconnect and the resourceUnregistered event to fire. This is causing
> problems for future download request.
>
> After the push message, I'm trying to have the client reconnect to the
> server. I'm currently doing something like this:
>
> public void reconnect(AjaxRequestTarget target, WebPage page) throws
> JSONException{
>                 JSONObject options = bus.getParameters().toJSON();
>                 List<AtmosphereBehavior> lstAtmoBehaviors =
> page.getBehaviors(AtmosphereBehavior.class);
>                 if(CollectionUtils.isNotEmpty(lstAtmoBehaviors)){
>                         options.put("url",
> page.urlFor(lstAtmoBehaviors.get(0),
> IResourceListener.INTERFACE, new PageParameters()).toString());
>                 }
>                 //wait a quarter of a second for the download to fire
> before reconnecting
>                 target.appendJavaScript("setTimeout(function(){jQuery('#" +
> page.getMarkupId() +
> "').wicketAtmosphere("+options.toString()+");},250);");
>         }
>
>
> This generates the same connection ajax call that the AtmosphereBehavior
> renderHead method method generates. I've verified it calls the EventBus
> resourceRegistered method. The uuid is unfortunately blank though.
>
> Manually hitting the browser refresh button re-registers the page with the
> uuid.
>
> Is there a fancy Wicket Atmosphere method to say "reconnect"? Or how do I
> get Wicket to generate a UUID? Or a setting that says "reconnect"
> automatically?
>
> THanks
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Atmosphere-Reconnect-after-Disconnect-tp4671118.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>