You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ben Titmarsh <be...@hotmail.co.uk> on 2013/09/03 16:58:04 UTC
Tapestry Server Push/Web Socket/Comet implementation
Hi Guys,
Is there any plan to bring some kind of Server Push implementation to Tapestry? I found a comet implementation (by Lance I think?) from a while back but haven't seen much movement in this area recently.
Cheers,
Ben.
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Martin Kersten <ma...@gmail.com>.
It wont make it into 5.4. Mr Ship talked about it back some time. You might
want to take a look Art athmospere. You should be able to include it into
Tapestry following the example oft cometd. This will bring you
socket.iosupport which should you bring everything for Server side
push .
Am Dienstag, 3. September 2013 schrieb Ben Titmarsh <
ben.titmarsh@hotmail.co.uk>:
> Hi Guys,
>
> Is there any plan to bring some kind of Server Push implementation to
Tapestry? I found a comet implementation (by Lance I think?) from a while
back but haven't seen much movement in this area recently.
>
> Cheers,
> Ben.
>
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Lance Java <la...@googlemail.com>.
It depends on how you want to use it. If you just simply want external
services to push JSON to the client and then write a whole lot of
javascript to update the DOM then that's fine.
With tapestry-cometd I wanted to the option to write ZERO javascript by
leveraging tapestry component events and templates. When a push message is
broadcast, tapestry-cometd fires a tapestry component event which returns a
block in much the same way as a normal component event. Tapestry-cometd
captures the markup and any scripts added via AjaxResponseRenderer which
are pushed to the client. The PushTarget is updated with the markup and
scripts are executed. This means that the push event is handled inside the
component, in the same way as a normal (non-push) component event, no extra
service classes are required, no extra javascript is required
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Norman Franke <no...@myasd.com>.
I've decided to start from scratch since there are lots of concepts to map.
It was pretty trivial to get Tapestry to delegate to the Atmosphere servlet (or even the MeteorServlet) like tapestry-cometd does. That seems to work really well, so thanks for that!
Next I wanted to be able to @Inject services into my handler class. I want to be able to write Atmosphere-based services the normal way, e.g. using @ManagedService. This scheme creates a ManagedAtmosphereHandler that calls into the class I've mapped to a specific URL. That all works, of course, but without @Inject support since nothing is going through the Tapestry IOC.
I got it working with Atmosphere 2.0.0RC3 and then everything changed in RC4, but it appears cleaner. Basically, you duplicate the org.atmosphere.annotation.Processor classes for every type you wish to enable IOC support. (In my case, basically everything that class that uses Class.newInstance() and replace with Registry.autobuild().
It appears to work. Can anyone think of any potential problems, since I'm not all that comfy with the Tapestry IOC's internals)?
I haven't started integrating broadcasters, broadcaster filters, or the like. I see that tapestry-cometd has done that, but I'm not really sure I need to since all the Atmosphere annotations should work.
Norman Franke
Answering Service for Directors, Inc.
www.myasd.com
On Sep 4, 2013, at 12:11 PM, Lance Java <la...@googlemail.com> wrote:
> I haven't done much research into Atmosphere… I found the docs to be quite
> cryptic and couldn't quickly find what I wanted.
>
> tapestry-cometd relies on a few concepts, If atmosphere has these same
> concepts then the switch will be easy, if not I guess it will be more
> difficult.
>
> 1. A Push Session - A serverside Map that lives for the duration of a
> subscription
> 2. Wildcard channels (when I subscribe to "/chat/**" I will get messages
> for /chat/cars and /chat/food/apples)
> 3. Subscription listeners - notified of subsctibe and unsubscribe events
> 4. Authorizers - permit / deny subscriptions
>
> Atmosphere suggests using annotations in most of the examples. CometD did a
> similar thing. I found that I needed to use the services under the hood
> instead of the annotations. I would assume that we would most likely use
> the "under the hood" services in atmosphere
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Lance Java <la...@googlemail.com>.
I haven't done much research into Atmosphere… I found the docs to be quite
cryptic and couldn't quickly find what I wanted.
tapestry-cometd relies on a few concepts, If atmosphere has these same
concepts then the switch will be easy, if not I guess it will be more
difficult.
1. A Push Session - A serverside Map that lives for the duration of a
subscription
2. Wildcard channels (when I subscribe to "/chat/**" I will get messages
for /chat/cars and /chat/food/apples)
3. Subscription listeners - notified of subsctibe and unsubscribe events
4. Authorizers - permit / deny subscriptions
Atmosphere suggests using annotations in most of the examples. CometD did a
similar thing. I found that I needed to use the services under the hood
instead of the annotations. I would assume that we would most likely use
the "under the hood" services in atmosphere
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Norman Franke <no...@myasd.com>.
Lance,
Interesting timing. I'm now also in need of a push solution. I did try tapestry-cometd and it is very nice.
As noted, I was wanting to use Atmosphere for the greatly simplified Javascript support and the support of multiple protocols.
I was thinking about modifying tapestry-cometd to use pure Atmosphere. Not sure how much work that will be, though. Have you looked into it any? If it seems relatively straight-forward, I may give it a go.
Norman Franke
Answering Service for Directors, Inc.
www.myasd.com
On Sep 4, 2013, at 3:43 AM, Lance Java <la...@googlemail.com> wrote:
> Hi Ben,
>
> Yes, tapestry-cometd is my creation… have you actually given it a go?
> Is there something you need it to do that it can't?
> I'm interested to hear your use case and if there's something that
> tapestry-cometd can't do, I can help you out.
>
> I'll give you a bit of a history lesson on how it evolved…
>
> As a previous committer to DWR, I initially started out integrating
> tapestry with DWR's reverse ajax. After speaking with DWR's lead developer,
> he informed me that DWR's push was not bullet proof and that he himself
> preferred cometd. So, I switched to cometd. I then found that cometd didn't
> work on some older servlet containers but that Atmosphere has cometd
> integration. So, I switched to atmosphere-cometd. So, tapestry-cometd
> currently sits on top of the AtmosphereServlet.
>
> One of the things that I dislike about CometD is that there is no "core"
> javascript implementation. Instead, you must either choose the jQuery or
> Dojo client libraries. I chose jquery and tapestry-cometd actually requires
> tapestry-jquery (I hate this!). If I had my time again, I would probably
> have written a straight tapestry-atmosphere integration. This seems to be
> the way forward since there is a core javascript implementation which does
> not require jquery / dojo or another "foundation" framework. It seems that
> most of the other java web frameworks out there have atmosphere integration
> so I think it's a safe bet.
>
> That being said, a rewrite on top of atmosphere would act in a very similar
> way to tapestry-cometd.
>
> 1. Put a PushTarget on a page
> 2. Give it a "topic" and an "event"
> 3. Publish a message to the "topic"
> 4. Return a "block" from the event (or execute some javascript)
> 5. Push the result to the PushTarget
>
> Howard has hinted that he'd like to add push to tapestry but I haven't
> heard much lately. I've recently become a tapestry committer and I may even
> provide this module myself in the fuure. As with the other tapestry
> comitters, I have a day job and a social life to juggle with contributing
> to open source. For the moment your options are to use tapestry-cometd or
> to use tapestry and atmosphere side by side.
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Kalle Korhonen <ka...@gmail.com>.
On Wed, Sep 4, 2013 at 12:43 AM, Lance Java <la...@googlemail.com>wrote:
> provide this module myself in the fuure. As with the other tapestry
> comitters, I have a day job and a social life to juggle with contributing
> to open source. For the moment your options are to use tapestry-cometd or
>
I thought this is the social life, no? :P
Kalle
RE: Tapestry Server Push/Web Socket/Comet implementation
Posted by Ben Titmarsh <be...@hotmail.co.uk>.
Sounds like good advice! I checked out your example implementation so will play around with it tomorrow. Thanks for all of the effort that you put into this library.
> Date: Thu, 5 Sep 2013 19:18:11 +0100
> Subject: Re: Tapestry Server Push/Web Socket/Comet implementation
> From: lance.java@googlemail.com
> To: users@tapestry.apache.org
>
> Note that if you're smart about naming your topics, you can use wildcards.
>
> eg: if user1 subscribes to /games/game1/user1 and user2 subscribes to
> /games/game1/user2
> you can send a message to both users by publishing to /games/game1/*
> or you can send a message to all game users via /games/**
>
> https://github.com/uklance/tapestry-cometd/wiki/Topics
>
>
> On 5 September 2013 18:12, Lance Java <la...@googlemail.com> wrote:
>
> > If you need to target individual users then you will definitely need a
> > topic per user. For game global messages you may decide to use a game
> > topic, or you probably know the users in a game and just send a message to
> > each user topic.
> >
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Lance Java <la...@googlemail.com>.
Note that if you're smart about naming your topics, you can use wildcards.
eg: if user1 subscribes to /games/game1/user1 and user2 subscribes to
/games/game1/user2
you can send a message to both users by publishing to /games/game1/*
or you can send a message to all game users via /games/**
https://github.com/uklance/tapestry-cometd/wiki/Topics
On 5 September 2013 18:12, Lance Java <la...@googlemail.com> wrote:
> If you need to target individual users then you will definitely need a
> topic per user. For game global messages you may decide to use a game
> topic, or you probably know the users in a game and just send a message to
> each user topic.
>
RE: Tapestry Server Push/Web Socket/Comet implementation
Posted by Lance Java <la...@googlemail.com>.
If you need to target individual users then you will definitely need a
topic per user. For game global messages you may decide to use a game
topic, or you probably know the users in a game and just send a message to
each user topic.
RE: Tapestry Server Push/Web Socket/Comet implementation
Posted by Ben Titmarsh <be...@hotmail.co.uk>.
Thanks Lance,
So if I have one shared topic that each client is subscribed to how do I push an event to a specific client? Presumably by adding some context (a "memberId") to each event and having each client only consume messages with their member id? Or would the approach be to create a per-member-id topic? At the very least I imagine needing a per-game topic so that I can have lots of games running concurrently without having too much dead traffic for each client.
Cheers,
Ben.
> Date: Thu, 5 Sep 2013 13:46:08 +0100
> Subject: RE: Tapestry Server Push/Web Socket/Comet implementation
> From: lance.java@googlemail.com
> To: users@tapestry.apache.org
>
> Hi Ben,
>
> I'm sure tapestry-cometd can handle this. Just add a PushTarget component
> to each user's page providing a "topic" and an "event". Messages are pushed
> to the PushTargets via PushManager.broadcast(topic, message). Every message
> will fire the component event and will either return a block or add a
> script via the AjaxResponseRenderer (or both). The response is then pushed
> to the client. Block updates will either append or prepend to the
> PushTarget's element or will replace the current contents.
>
> One improvement that could be made to tapestry-cometd is to allow 1
> PushTarget to subscribe to multiple topics. This way each user could have a
> private topic (for peer to peer messages) and a public topic that everyone
> can see. The current workaround is to have two PushTargets on a page.
>
> More info here:
> https://github.com/uklance/tapestry-cometd/wiki/Pushing-javascript-to-the-client
> https://github.com/uklance/tapestry-cometd
>
> Demo app here:
> https://github.com/uklance/tapestry-cometd-demo
RE: Tapestry Server Push/Web Socket/Comet implementation
Posted by Lance Java <la...@googlemail.com>.
Hi Ben,
I'm sure tapestry-cometd can handle this. Just add a PushTarget component
to each user's page providing a "topic" and an "event". Messages are pushed
to the PushTargets via PushManager.broadcast(topic, message). Every message
will fire the component event and will either return a block or add a
script via the AjaxResponseRenderer (or both). The response is then pushed
to the client. Block updates will either append or prepend to the
PushTarget's element or will replace the current contents.
One improvement that could be made to tapestry-cometd is to allow 1
PushTarget to subscribe to multiple topics. This way each user could have a
private topic (for peer to peer messages) and a public topic that everyone
can see. The current workaround is to have two PushTargets on a page.
More info here:
https://github.com/uklance/tapestry-cometd/wiki/Pushing-javascript-to-the-client
https://github.com/uklance/tapestry-cometd
Demo app here:
https://github.com/uklance/tapestry-cometd-demo
RE: Tapestry Server Push/Web Socket/Comet implementation
Posted by Ben Titmarsh <be...@hotmail.co.uk>.
Hey Lance,
Thanks for the detailed response. I haven't checked out tapestry-cometd yet but I certainly will and it would be great to get this integrated as a core Tapestry module. Congratulations on becoming a committer!
My use case is to create a simple browser-based multiplayer game. At it's core the game is played by 8 people and each person is asked to make a selection from 15 choices. Once each client has sent their selection to the server I'd like the server to send an event to each client with a new set of 14 choices. This process is called Drafting if you are familiar with card games. I'm quite unfamiliar with this paradigm generally so I'd have to work out how the server should main the state of the game and all of the individual client connections.
Do you think this is an appropriate use case for the tapestry-cometd library?
Cheers,
Ben.
> Date: Wed, 4 Sep 2013 08:43:15 +0100
> Subject: Re: Tapestry Server Push/Web Socket/Comet implementation
> From: lance.java@googlemail.com
> To: users@tapestry.apache.org
>
> Hi Ben,
>
> Yes, tapestry-cometd is my creation… have you actually given it a go?
> Is there something you need it to do that it can't?
> I'm interested to hear your use case and if there's something that
> tapestry-cometd can't do, I can help you out.
>
> I'll give you a bit of a history lesson on how it evolved…
>
> As a previous committer to DWR, I initially started out integrating
> tapestry with DWR's reverse ajax. After speaking with DWR's lead developer,
> he informed me that DWR's push was not bullet proof and that he himself
> preferred cometd. So, I switched to cometd. I then found that cometd didn't
> work on some older servlet containers but that Atmosphere has cometd
> integration. So, I switched to atmosphere-cometd. So, tapestry-cometd
> currently sits on top of the AtmosphereServlet.
>
> One of the things that I dislike about CometD is that there is no "core"
> javascript implementation. Instead, you must either choose the jQuery or
> Dojo client libraries. I chose jquery and tapestry-cometd actually requires
> tapestry-jquery (I hate this!). If I had my time again, I would probably
> have written a straight tapestry-atmosphere integration. This seems to be
> the way forward since there is a core javascript implementation which does
> not require jquery / dojo or another "foundation" framework. It seems that
> most of the other java web frameworks out there have atmosphere integration
> so I think it's a safe bet.
>
> That being said, a rewrite on top of atmosphere would act in a very similar
> way to tapestry-cometd.
>
> 1. Put a PushTarget on a page
> 2. Give it a "topic" and an "event"
> 3. Publish a message to the "topic"
> 4. Return a "block" from the event (or execute some javascript)
> 5. Push the result to the PushTarget
>
> Howard has hinted that he'd like to add push to tapestry but I haven't
> heard much lately. I've recently become a tapestry committer and I may even
> provide this module myself in the fuure. As with the other tapestry
> comitters, I have a day job and a social life to juggle with contributing
> to open source. For the moment your options are to use tapestry-cometd or
> to use tapestry and atmosphere side by side.
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Lance Java <la...@googlemail.com>.
Hi Ben,
Yes, tapestry-cometd is my creation… have you actually given it a go?
Is there something you need it to do that it can't?
I'm interested to hear your use case and if there's something that
tapestry-cometd can't do, I can help you out.
I'll give you a bit of a history lesson on how it evolved…
As a previous committer to DWR, I initially started out integrating
tapestry with DWR's reverse ajax. After speaking with DWR's lead developer,
he informed me that DWR's push was not bullet proof and that he himself
preferred cometd. So, I switched to cometd. I then found that cometd didn't
work on some older servlet containers but that Atmosphere has cometd
integration. So, I switched to atmosphere-cometd. So, tapestry-cometd
currently sits on top of the AtmosphereServlet.
One of the things that I dislike about CometD is that there is no "core"
javascript implementation. Instead, you must either choose the jQuery or
Dojo client libraries. I chose jquery and tapestry-cometd actually requires
tapestry-jquery (I hate this!). If I had my time again, I would probably
have written a straight tapestry-atmosphere integration. This seems to be
the way forward since there is a core javascript implementation which does
not require jquery / dojo or another "foundation" framework. It seems that
most of the other java web frameworks out there have atmosphere integration
so I think it's a safe bet.
That being said, a rewrite on top of atmosphere would act in a very similar
way to tapestry-cometd.
1. Put a PushTarget on a page
2. Give it a "topic" and an "event"
3. Publish a message to the "topic"
4. Return a "block" from the event (or execute some javascript)
5. Push the result to the PushTarget
Howard has hinted that he'd like to add push to tapestry but I haven't
heard much lately. I've recently become a tapestry committer and I may even
provide this module myself in the fuure. As with the other tapestry
comitters, I have a day job and a social life to juggle with contributing
to open source. For the moment your options are to use tapestry-cometd or
to use tapestry and atmosphere side by side.
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Martin Kersten <ma...@gmail.com>.
Lance talked about that this very same approach can be used to bind
atmosphere into the picture. This library would provide socket.io support
which others on this list claimed to have used successfully (check the
archive and search for atmosphere).
2013/9/3 Boris Horvat <ho...@gmail.com>
> I am using it and I can say that it does job pretty well (for me at least -
> my requirements are very basic at the moment but it will change eventually
> I guess)
>
>
> On Tue, Sep 3, 2013 at 8:19 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
> > On Tue, 03 Sep 2013 11:58:04 -0300, Ben Titmarsh <
> > ben.titmarsh@hotmail.co.uk> wrote:
> >
> > Hi Guys,
> >>
> >
> > Hi!
> >
> > Is there any plan to bring some kind of Server Push implementation to
> >> Tapestry? I found a comet implementation (by Lance I think?) from a
> while
> >> back but haven't seen much movement in this area recently.
> >>
> >
> > I've never used tapestry-cometd (yep, written by Lance) myself, but have
> > you used it and found it lacking something?
> >
> > --
> > Thiago H. de Paula Figueiredo
> >
> > ------------------------------**------------------------------**---------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
> users-unsubscribe@tapestry.apache.org>
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Sincerely
> *Boris Horvat*
>
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Boris Horvat <ho...@gmail.com>.
I am using it and I can say that it does job pretty well (for me at least -
my requirements are very basic at the moment but it will change eventually
I guess)
On Tue, Sep 3, 2013 at 8:19 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Tue, 03 Sep 2013 11:58:04 -0300, Ben Titmarsh <
> ben.titmarsh@hotmail.co.uk> wrote:
>
> Hi Guys,
>>
>
> Hi!
>
> Is there any plan to bring some kind of Server Push implementation to
>> Tapestry? I found a comet implementation (by Lance I think?) from a while
>> back but haven't seen much movement in this area recently.
>>
>
> I've never used tapestry-cometd (yep, written by Lance) myself, but have
> you used it and found it lacking something?
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Sincerely
*Boris Horvat*
Re: Tapestry Server Push/Web Socket/Comet implementation
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 03 Sep 2013 11:58:04 -0300, Ben Titmarsh
<be...@hotmail.co.uk> wrote:
> Hi Guys,
Hi!
> Is there any plan to bring some kind of Server Push implementation to
> Tapestry? I found a comet implementation (by Lance I think?) from a
> while back but haven't seen much movement in this area recently.
I've never used tapestry-cometd (yep, written by Lance) myself, but have
you used it and found it lacking something?
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org