Quick Question (Web Development Noobie)

16 views
Skip to first unread message

David Illescas

unread,
Oct 6, 2011, 6:02:04 AM10/6/11
to Google Web Toolkit
I am really interested in the GWT technology and would like to learn
more. I have the following problem.

I want to run a simulation on the server, such that two separate
clients accessing that simulation through a browser will see the same
simulation. With GWT, I am not sure how this is done, since two
clients seem to result in two separate generated server instances(??)
with no sharing of data. I want to avoid having two separate
simulations running because two clients are accessing the server;
there should only be one, which both clients look at.

The only way I can of to share data between clients is to maintain
state in a database. Then the clients would simply receive data from
that shared database, and the data displayed on both client would
match. Are there better ways?

Juan Pablo Gardella

unread,
Oct 6, 2011, 9:02:44 AM10/6/11
to google-we...@googlegroups.com
You must have in some points share data (in your case), if you want N clients see same things. So a DB is fine. If you don't use GWT you have the same problem.

Think that GWT compile to javascript, so if you make singletons, are singletons per tab in browser.

Juan.

2011/10/6 David Illescas <dill...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Jens

unread,
Oct 6, 2011, 9:56:43 AM10/6/11
to google-we...@googlegroups.com
Well there are a couple of different ways. 

First off if you only use a single server instead of a server cluster then you can create a singleton class that manages your simulations and clients that connect to your server can ask this singleton class about live information of a specific simulation that is currently running. Of course you could also save "snapshots" of your simulation data to a database and let the clients fetch these snapshots. But depending on the complexity of the simulation you may end up with a lot of database queries to save the snapshots. But maybe you want to snapshot anyways because you want to be able to resume the simulation if the server crashes or something like that.

If you have a server cluster things get a bit more complicated if you want live information without using simulation snapshots stored in a database. Because in that case you first have to identify the server on which the requested simulation runs and then find a way to communicate with that server to get live information. 
For a cluster setup something like Terracotta (terracotta.org) can also be interesting. It can create a JVM-level cluster which allows you to create objects that are shared/accessible by all JVMs in that cluster. Which instance should be shared can be defined in a configuration file. Take a look at http://video.google.com/videoplay?docid=7660457673499305140 to get an impression of what terracotta does.

-- J.
Reply all
Reply to author
Forward
0 new messages