views:

19

answers:

1

Hi guys,

I have to implement gmail style chatting in my asp.net website. now i know much has been said in this regard here and other forums...about COMET and its befits....

i recently saw this site www.indyarocks.com and when i profiled their website i found out that for chatting they send a async request and the page waits until the server has some data to return and only after the page returns....(i mean it shows status 200 OK) and again a request is dispatched.

i have implemeted chat in my website in which i poll the database after 5 sec for any new chat...so i want to know if i send a request using ASP.NET AJAX to a web method and keep on looping on the server until it has some data to return and then return to the webpage that called it is it a good approach and if not what are its demerits????

the code that i can use

<WebMethod(EnableSession:=True)> _
    Public Function looper(ByVal x As String) As String
        Dim flag As Boolean = False
        While (flag = False)
            Dim ans As String = getScalar("select 1 from Chat where sent_by=1")
            If Not ans Is Nothing Then
                flag = True
            End If
        End While
        Return "x"
    End Function

here i can loop over the server until it has some data

in any case is it better than the polling approach????

Does anyone have suggestions to improve this approach???

A: 

Its better than polling approach from client side

Why, because

  • It avoids server roundtrip - saves lot of time
  • And avoid unnessary calls to server (Polling approach calls the webmethod even though the data is not available)

In other hand, your current COMET approach, Server calls are minimal from javascript because the new request only be made from client if the server return the updated data.

So keep up with the current design

Cheers

Ramesh Vel
thanks for taking the time to answer...but i am not sure whether continuously looping in the web method would cause the server to overload if many uses are accessing it...something about the ASP.NEt worker process becoming overloaded. ...in any case though it is better than polling approach
Pankaj Kumar
continuously looping in the web method based on timer is not a good practise, Instead COMET solve this by long running server calls.. thats wat am describing above
Ramesh Vel