2

I'm not sure if this is possibly, I may end up having to change how I'm doing this.

I have an Android app that's mostly just a webview that displays the mobile version of a site, which is in .NET. The chat room uses jQuery and updates every 1.5 seconds using ajax. The box you type in though is part of the Android app though. When you submit a message it's sent to a REST page and then added to the messages list. The users session is on the chat page, not on the REST page.

Because of the 1.5 second delay between refreshes it can make the chat seem laggy. I'd like to somehow trigger an event to immediately update the messages for that user. I'm wondering if this can be done using jQuery or javascript.

Has any done something like that, or know how this can be done?

GregInWI2
  • 884
  • 1
  • 16
  • 25
  • If I'm reading this right, you want to update the chat list when the user submits a new message? If so, how are you triggering the submit to the server? – Alastair Pitts Oct 12 '10 at 03:09
  • There are two different ways. If they are using the mobile app the message is sent to a rest page. If they are using the actual site then the message box is on the chat page. I'm storing the messages both in the database and memcache. The chat page makes a call to get new messages every 1.5 seconds. – GregInWI2 Oct 12 '10 at 13:04

2 Answers2

0

I have not tested "comet and jquery" but it worked for somebody.

About Comet(Programming)

Community
  • 1
  • 1
Reigel
  • 61,807
  • 21
  • 115
  • 133
0

I've been pondering about the exact same question for some time. I've never actually implemented anything for my own application but I can point you in the right direction.

What you are looking for, especially for chat web apps, is long-polling or try googling for cometd. Even better if you are developing using HTML5 technologies, Web Sockets is the right thing to use for this scenario. Web sockets help reduce the number of times your app contacts the server hence, making your application much speedier.

Sorry I don't have any code examples. Above are just my $0.02

Mark
  • 1,996
  • 4
  • 25
  • 38