tags:

views:

64

answers:

2

hello everybody,

I am working on a chatting application and i was using simple ajax polling to retrieve the new chat but its working good because there are few more xmlHttp request to check online status and to send chat to others and some for other reason, so i think there are many request in my form thats why its not working so now i want to do these things in Comet style. so please tell me about it that how to do.

this is sever side code

Dim output As String = JavaScriptConvert.SerializeObject(newChat)               
                    Response.Flush()
                    Response.Clear()
                    Response.Write(output)
                    Response.End()

and at client side i was set a time out to check continuously.

A: 

You do understand what Comet is, right? It means leaving the http connection in a hanging state (as if the download has halted) until the server has something interesting to tell the client.

The client would not have a timeout. It would simply request again if the current download ends.

Timeouts might occur on the server to try to pre-empt the network timeouts that might occur in hardware on the route from server to client (proxies etc).

Writing a Comet server is not a trivial undertaking. It seems you need a better understanding of the concepts before embarking on such a perilous adventure.

spender
A: 

I can't really give a good response to your question because the code you've included so far isn't clear as to the background of what your server is doing. Comet is nice, but its not a panacea, and as mentioned before there are some concepts that you'll need to understand in order to successfully implement.

I recommend that you be intimately familiar with the page life cycle of an asp.net page, how that life cycle is represented in your client's request object (read xmlhttprequest.readystate,) and how your server.

As far as what code you have included, in my experience, calling Response.End() or having an end of the function closes the response which is not necessarily what you want to happen.

In a custom server that we use, I use an event wait handle to signal and wait for user input from the client. I also have to make sure that if the user is sending a lot of requests that the data is either packaged and handled at the server correctly, or that those requests don't block the viewstate thread (which handles that output back to the client.)

I believe, that the least amount of complexity is achieved when you use only two requests. (I believe this is also per specification, but I can't seem to find it atm.)

For a good read, check out Comet and Reverse Ajax (available via apress)

fauxtrot