As Vitali said, there are some common pitfalls when trying to
implement something along the lines of whatyou're trying to do.
There have been plenty of discussions related to chat implementations
and server-push. You might want to look at this docs:
http://docs.codehaus.org/display/JETTY/GWT+RPC+Examples
http://code.google.com/docreader/#p=google-web-toolkit-incubator&s=google-web-toolkit-incubator&t=ServerPushFAQ
And also comment on this bug if you have any problems or even if you
succeed:
http://code.google.com/p/google-web-toolkit/issues/detail?id=267

Hope it helps,

Salvador

On Apr 23, 9:40 am, "davidst...@gmail.com" <davidst...@gmail.com>
wrote:
> I open two clients, and trying to send a message from one to another.
> So i have two requests hanging on server's side, and the third one
> trying to send the message.
> the server side is like this :
>
>         @Override
>         public ArrayList<Event> getEvents( Integer sessionId )
>         {
>                 UserInfo user = getUserById( sessionId );;
>                 ArrayList< Event > events = null ;
>
>                 if( user != null )
>                 {
>                         if( user.events.size() == 0 )
>                         {
>                                 try
>                                 {
>                                         synchronized( user )
>                                         {
>                                                 user.wait( 20*1000 );
>                                         }
>                                 }
>                                 catch ( InterruptedException ignored ) {}
>                         }
>                         synchronized( user )
>                         {
>                                 events = user.events;
>                                 user.events = = new ArrayList<Event>();  ;
>                         }
>                 }
>                 return events;
>         }
>
> And the sendEvent() on the server side is like this :
>
>         @Override
>         public void sendEvent( Integer senderId, Integer recieverId, String
> message )
>         {
>                System.out.println( senderId + "entered the sendMessage
> method" );
>
>                 UserInfo reciever = getUserById( recieverId );
>                 MessageEvent me = new MessageEvent( senderId , message );
>
>                 if( reciever != null )
>                 {
>                         synchronized( reciever )
>                         {
>                                 reciever.events.add( me );
>                                 reciever.notifyAll();
>                         }
>                 }
>         }
> So I have two clients opened in hosted mode. For debugging
> i put System.out.println( senderId + "entered the sendEvent method" );
> command at the enter
> to sendEvent() method. And the message "senderId entered the sendEvent
> method" appeared, only when
> one of the clients exited the getEvents(). So maybe the problem is
> that both clients are opened at the same
> computer, or maybe it's because of hosted mode  ?
>
> On Apr 22, 11:56 pm, Vitali Lovich <vlov...@gmail.com> wrote:
>
> > Most browsers only support 2 outstanding AJAX events - that may be what you
> > are running into.  Without knowing what other calls you make, I cannot make
> > a recommendation.
>
> > One thing that does come to mind is that I hope you only call getEvents once
> > on startup.
>
> > On Wed, Apr 22, 2009 at 4:47 PM, davidst...@gmail.com
> > <davidst...@gmail.com>wrote:
>
> > > Hi.
> > > I'm trying to implement chat on my GWT app. So client has getEvents()
> > > function implemented like this :
>
> > >   public void getEvents( )
> > >    {
> > >        networkSvc.getEvents(
> > >                       new AsyncCallback< ArrayList<Event> >()
> > >                        {
> > >                                public void onSuccess( ArrayList< Event >
> > > events )
> > >                                {
> > >                                        handleEvents( events );
> > >                                        networkSvc.getEvents( this );
> > >                                }
> > >                                public void onFailure( Throwable caught )
> > >                                {
> > >                                        System.out.println("eventListner " 
> > > +
> > > caught );
> > >                                }
> > >                        }
> > >        );
> > >    }
>
> > > This func in an endless loop with the server .
> > > at the server side getEvents goes to sleep for 30 sec or till events
> > > approaching.
> > > The second function is sendEvent() function.
> > > As i see, i can't send an event to server while the server processing
> > > the previos request.
> > > I mean it looks like the sendEvent() waits till the getEvents() gets
> > > the response,
> > > and just after that it sends its own request.
> > > Is that right, or there is some bug in my algorithm ?
--~--~---------~--~----~------------~-------~--~----~
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-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to