I wrote a very basic webapp that synchronizes a data model on a server
between many clients. Essentially, the model is the position of a
dialog box that clients can move a box around on their screen. When a
move occurs, that change is sent to the server and all other clients
immediately see the box update to its latest position on their screens
as well.
The way I implemented this is through these methods:
In DataServiceImpl.java, there is the getLatestModelFromServer()
method. The client calls this method through RPC to receive model
updates from the server when any changes are made.
In the client code, whenever the client drags the dialog box and
releases (onmouseup), the client calls the updateServerModel() method
through RPC.
In getLatestModelFromServer(), there is the following loop:
while(!thereAreUpdates) {
wait();
}
// after update occurs, return the latest server model to the client.
In updateServerModel(), whenever a client updates the server's model
(i.e. the coordinate position of the dialog box), the method calls
NotifyAll() and sets thereAreUpdates to true, which makes all clients
waiting for a response from getLatestModelFromServer() get the latest
model. When they do, these clients call getLatestModelFromServer()
again (in the onSuccess method of the callback). Thus, clients always
have a persistent connection with the server, always waiting for
updates.
The code works as designed, concurrency issues aside. One client can
drag the dialog box anywhere and when he releases the drag, all other
clients connected to the server through getLatestModelFromServer()
receive the new coordinates and see their box move from the old
position to the new one. But here is my problem:
In Tomcat Manager, one persistent request per client is created while
the webapp is running. However, when I close all the web browser
windows, the following shows up under Server Status:
POST: /[application name]//DataService HTTP/1.1
...and it shows up one per client I used! The oddest thing is, even
when I completely reload the application context, these ghost
connections are still there. I cannot get rid of these without
restarting the entire Tomcat server.
I must not be understanding something because I thought reloading the
context resets this kind of thing. Does anyone know why these
connections persist even after the browser windows are closed and the
application is reloaded? Is there any way to terminate these
connections? Each ghost connection costs a thread =(
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---