What would be a better solution
looking at the fact that I need the
new data EVERY SECOND, pulling from
the client or pushing with the server?
I don't think it doesn't matter that much, as the time between requests and the time new data will be available is rather short. I would just instantiate a new XMLHttpRequest at the client after the previous one succeeded. You could send the server the last received data (if not too big) so it can compare that data with the current one available on the server and only send something back when new data is available.
Also the item ID's that are on the
server side (with the variable's that
ID got) can change and when the client
refreshes the page he needs to get the
oldest (and living) ID's. This would
mean that my jquery/javascript on the
client side must know which ID's he
got on the page, what is best way to
do this?
I'm not totally sure I understand what you mean, but if I'm right you can just store every name/value pair in an object. When a new variable arrives at the client, it doesn't overwrite existing data; when a certain variable is already present, it is updated with the latest value. It could look like:
{ first_variable: 345,
second_one: "foo",
and_the_third: ["I", "am", "an", "array,", "hooray!"]
}
and when a new state of second_one
arrives, e.g. "bar"
, the object is updated to:
{ first_variable: 345,
second_one: "bar",
and_the_third: ["I", "am", "an", "array,", "hooray!"]
}
Last thing is that I can't find a good
(not to expensive) comet library/api
for asp.net (C#). Anyone ever used a
comet library with good results?
I don't have any experience with ASP.NET, but do you need such a library for this? Can't you just program the server-side code yourself, which, as I said, leaves the connection open and periodically (continually) compares the current state with the previous sent state?
UPDATE: To show it's not that difficult to keep a connection open at the server side, I'll show you a long-polling simulation I wrote in PHP:
<?php
sleep(5);
?>
<b>OK!</b>
Instead of letting the process sleep
a few seconds, you can easily test for changes of the state in a loop. And instead of sending an arbitrary HTML element, you can send the data back, e.g. in JSON notation. I can't imagine it would be that hard to do this in ASP.NET/C#.