|
|
|
start date: Thu, 23 Aug 2007 09:51:11 +0200,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Piotr Nowak
|
|
2
NH
|
|
3
Piotr Nowak
|
|
4
Aidy
|
|
5
Piotr Nowak
|
|
6
Aidy
|
|
7
Patrice http://www.chez.com/scribe/
|
|
8
Piotr Nowak
|
|
9
Patrice http://www.chez.com/scribe/
|
|
10
Piotr Nowak
|
Ajax Asynchronous refresh. Is it possible ?
Hi,
Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.
I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.
The problem is that refreshing evry n seconds has to much impact on my
web server. The refresh action should be taken only when something
really happens that makes sense
Is it possible ?
greets, peter
Date:Thu, 23 Aug 2007 09:51:11 +0200
Author:
|
RE: Ajax Asynchronous refresh. Is it possible ?
I dont think that is possible, you cant "notify" a web browser client that
something has changed on the server. That is the nature of web sites and web
applications, they are "stateless".
"Piotr Nowak" wrote:
> Hi,
>
> Say i have a server process which listens for some changes in database.
> When a change occurs i want to refresh my page in browser by notyfinig it.
>
> I do not want to refresh my page i.e. every 5 seconds, i just want to
> refresh it ONLY on server change just like desktop applications do.
>
> The problem is that refreshing evry n seconds has to much impact on my
> web server. The refresh action should be taken only when something
> really happens that makes sense
>
> Is it possible ?
>
> greets, peter
>
Date:Thu, 23 Aug 2007 01:20:01 -0700
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
NH pisze:
> I dont think that is possible, you cant "notify" a web browser client that
> something has changed on the server. That is the nature of web sites and web
> applications, they are "stateless".
>
> "Piotr Nowak" wrote:
>
>> Hi,
>>
>> Say i have a server process which listens for some changes in database.
>> When a change occurs i want to refresh my page in browser by notyfinig it.
>>
>> I do not want to refresh my page i.e. every 5 seconds, i just want to
>> refresh it ONLY on server change just like desktop applications do.
>>
>> The problem is that refreshing evry n seconds has to much impact on my
>> web server. The refresh action should be taken only when something
>> really happens that makes sense
>>
>> Is it possible ?
>>
>> greets, peter
>>
stateless means that theres no information about previous request in the
new one, its forgotten.
i just want to get one simple response right from the server when
something happens to update my client browser view.
Date:Thu, 23 Aug 2007 10:28:47 +0200
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
As long as there is some asp.net code you can run that will return a true or
false as to the server being updated then this is possible. Use an ajax
call every x seconds and when it returns true issue a page reload via
javascript.
"Piotr Nowak" wrote in message
news:fajeb8$ont$1@atlantis.news.tpi.pl...
> Hi,
>
> Say i have a server process which listens for some changes in database.
> When a change occurs i want to refresh my page in browser by notyfinig it.
>
> I do not want to refresh my page i.e. every 5 seconds, i just want to
> refresh it ONLY on server change just like desktop applications do.
>
> The problem is that refreshing evry n seconds has to much impact on my web
> server. The refresh action should be taken only when something really
> happens that makes sense
>
> Is it possible ?
>
> greets, peter
Date:Thu, 23 Aug 2007 09:38:25 +0100
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
Aidy pisze:
> As long as there is some asp.net code you can run that will return a true or
> false as to the server being updated then this is possible. Use an ajax
> call every x seconds and when it returns true issue a page reload via
> javascript.
>
> "Piotr Nowak" wrote in message
> news:fajeb8$ont$1@atlantis.news.tpi.pl...
>> Hi,
>>
>> Say i have a server process which listens for some changes in database.
>> When a change occurs i want to refresh my page in browser by notyfinig it.
>>
>> I do not want to refresh my page i.e. every 5 seconds, i just want to
>> refresh it ONLY on server change just like desktop applications do.
>>
>> The problem is that refreshing evry n seconds has to much impact on my web
>> server. The refresh action should be taken only when something really
>> happens that makes sense
>>
>> Is it possible ?
>>
>> greets, peter
>
>
yes, but the page reload is not as much impact as server side actions
because every x second i would have to do a database hit to check if
something changed, then do a page refresh.
im not shure if i was enough clear..
Date:Thu, 23 Aug 2007 10:44:57 +0200
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
No the server can't reach a web client. This is always the client that sends
a request to the server and the server only responds to incoming requests.
You could issue an AJAX call to the server that just tell if the client
should be updated. If not you have nothing more to do, if yes you can issue
your more complex ajax calls that would update parts of your pages...
Youn may want to explain a bit more what you are trying to do...
--
Patrice
"Piotr Nowak" a crit dans le message de news:
fajeb8$ont$1@atlantis.news.tpi.pl...
> Hi,
>
> Say i have a server process which listens for some changes in database.
> When a change occurs i want to refresh my page in browser by notyfinig it.
>
> I do not want to refresh my page i.e. every 5 seconds, i just want to
> refresh it ONLY on server change just like desktop applications do.
>
> The problem is that refreshing evry n seconds has to much impact on my web
> server. The refresh action should be taken only when something really
> happens that makes sense
>
> Is it possible ?
>
> greets, peter
Date:Thu, 23 Aug 2007 10:54:36 +0200
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
> yes, but the page reload is not as much impact as server side actions
> because every x second i would have to do a database hit to check if
> something changed, then do a page refresh.
> im not shure if i was enough clear..
It's hard to advise on solutions without knowing more about how it can be
determined when a refresh is needed. You say;
"i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it."
Could your process do something like create/update a file saying to refresh,
your ajax call will see if the data in the file indicates a refresh is
needed. If it is then the call will return that and update the file to set
it back to no refresh being needed. That way every x seconds you are merely
accessing the file system and not the database.
Date:Thu, 23 Aug 2007 09:53:57 +0100
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
Patrice pisze:
> No the server can't reach a web client. This is always the client that sends
> a request to the server and the server only responds to incoming requests.
>
> You could issue an AJAX call to the server that just tell if the client
> should be updated. If not you have nothing more to do, if yes you can issue
> your more complex ajax calls that would update parts of your pages...
>
> Youn may want to explain a bit more what you are trying to do...
> --
> Patrice
>
> "Piotr Nowak" a crit dans le message de news:
> fajeb8$ont$1@atlantis.news.tpi.pl...
>> Hi,
>>
>> Say i have a server process which listens for some changes in database.
>> When a change occurs i want to refresh my page in browser by notyfinig it.
>>
>> I do not want to refresh my page i.e. every 5 seconds, i just want to
>> refresh it ONLY on server change just like desktop applications do.
>>
>> The problem is that refreshing evry n seconds has to much impact on my web
>> server. The refresh action should be taken only when something really
>> happens that makes sense
>>
>> Is it possible ?
>>
>> greets, peter
>
>
Sure its quite generic problem.
Imagine you develop a online game, like ogame.
There's a lot action behind the scenes, players are making some actions
that take some time (training soldiers, building houses) which takes
some time (minutes, hours, even days). after time is up and soldier,
building is finished a browser should be refreshed to say - 'hey, your
request is done now !, you succesfully trained 5 soldiers and built one
house'.
So, it doesnt make sense to poll every 5 seconds if action of building a
house last 2 days ! Divide 2days by 5 seconds and you get number of
waisted requests to check if action is done.
was this enough clear for You ?
best regards
Date:Thu, 23 Aug 2007 11:09:55 +0200
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
My first idea would be then to avoid polling at a particular fixed interval.
For example the AJAX call could return the next action with an estimated
time to complete (if 0 you can then can then perform the actual action). You
can now use this information to schedule your next AJAX call. If the user
does some action, you'll issue this call again (in case the new action would
be earlier than the previous one) etc...
In some cases the browser is just used to download a software especially if
a quick multiple players interaction is needed...
---
Patrice
"Piotr Nowak" a crit dans le message de news:
fajj6m$j7p$1@nemesis.news.tpi.pl...
> Patrice pisze:
>> No the server can't reach a web client. This is always the client that
>> sends a request to the server and the server only responds to incoming
>> requests.
>>
>> You could issue an AJAX call to the server that just tell if the client
>> should be updated. If not you have nothing more to do, if yes you can
>> issue your more complex ajax calls that would update parts of your
>> pages...
>>
>> Youn may want to explain a bit more what you are trying to do...
>> --
>> Patrice
>>
>> "Piotr Nowak" a crit dans le message de
>> news: fajeb8$ont$1@atlantis.news.tpi.pl...
>>> Hi,
>>>
>>> Say i have a server process which listens for some changes in database.
>>> When a change occurs i want to refresh my page in browser by notyfinig
>>> it.
>>>
>>> I do not want to refresh my page i.e. every 5 seconds, i just want to
>>> refresh it ONLY on server change just like desktop applications do.
>>>
>>> The problem is that refreshing evry n seconds has to much impact on my
>>> web server. The refresh action should be taken only when something
>>> really happens that makes sense
>>>
>>> Is it possible ?
>>>
>>> greets, peter
>>
>>
> Sure its quite generic problem.
>
> Imagine you develop a online game, like ogame.
> There's a lot action behind the scenes, players are making some actions
> that take some time (training soldiers, building houses) which takes some
> time (minutes, hours, even days). after time is up and soldier, building
> is finished a browser should be refreshed to say - 'hey, your request is
> done now !, you succesfully trained 5 soldiers and built one house'.
>
> So, it doesnt make sense to poll every 5 seconds if action of building a
> house last 2 days ! Divide 2days by 5 seconds and you get number of
> waisted requests to check if action is done.
>
> was this enough clear for You ?
>
> best regards
>
Date:Thu, 23 Aug 2007 13:13:05 +0200
Author:
|
Re: Ajax Asynchronous refresh. Is it possible ?
Thanks, i have been thinking quite the same - time estimation.
regards
Date:Thu, 23 Aug 2007 13:16:53 +0200
Author:
|
|
|