How to get informed Clients Disconnected from the Server
Moderator: General Moderators
-
llcoollasa
- Forum Newbie
- Posts: 1
- Joined: Wed Jan 20, 2010 12:31 am
How to get informed Clients Disconnected from the Server
HI everyone?
1. is there a way to determine how many clients(web browsers) connected to the server??
2. is there a way how to send a message to the client from the server. Not client to server...
Example:
Assume there is a web site that showing online score of a game.
How was it done?
is there a client script(js) that request score from the sever or server send score to the client.
i like to learn.....
1. is there a way to determine how many clients(web browsers) connected to the server??
2. is there a way how to send a message to the client from the server. Not client to server...
Example:
Assume there is a web site that showing online score of a game.
How was it done?
is there a client script(js) that request score from the sever or server send score to the client.
i like to learn.....
Re: How to get informed Clients Disconnected from the Server
Yep. Something like a "listen" function on the client polls for updates every few seconds. A "send" command on the server would probably just queue the message to be sent the next time the client polls for itllcoollasa wrote:is there a client script(js) that request score from the sever or server send score to the client.
Re: How to get informed Clients Disconnected from the Server
Technically the client never listens, the best you'll get (outside of a browser-plugin) is a periodic request. 
Re: How to get informed Clients Disconnected from the Server
Technically nothing software related listens, it is all "periodic" CPU operations, which is why I think this question is a broader question, one about abstraction itself
The computer doesnt have to technically listen. If a function named listen really does period requests, for all applicable purposes we should be able to say it listens! If it quacks like a duck, its a duck.
The computer doesnt have to technically listen. If a function named listen really does period requests, for all applicable purposes we should be able to say it listens! If it quacks like a duck, its a duck.
- PHPHorizons
- Forum Contributor
- Posts: 175
- Joined: Mon Sep 14, 2009 11:38 pm
Re: How to get informed Clients Disconnected from the Server
There's different levels of "being technical" and sometimes those levels can contradict each other.
In this case, josh's level of being technical goes to an extreme and begins to lose touch with the actual substance of the problem here. There is a concept called persistent connections (like ftp) where computer a establishes a connection to computer b. Now, either computer a or computer b can send messages to the other one, and the other one can respond.
Using http protocol, computer a can send a request to computer b and computer b can respond, but computer b cannot send a request to computer a. Hence the reason computer a must continually poll computer b in order for computer b to be able to respond within a reasonable amount of time to a certain change.
So Jenk's technicality is about as close to being the most relevant to this situation as is possible.
Cheers
ps. Josh, that doesn't mean I disagree with ya, it's just that you're getting into the weeds to a point that it's not as relevant to this situation. For instance, persistent connections are a whole heck of a lot more efficient than polling. Your technicality abstracts that away and pretty much says there is no difference on the grounds that "listening" is never really a reality, so everything polls when you look down to a deep enough level.
In this case, josh's level of being technical goes to an extreme and begins to lose touch with the actual substance of the problem here. There is a concept called persistent connections (like ftp) where computer a establishes a connection to computer b. Now, either computer a or computer b can send messages to the other one, and the other one can respond.
Using http protocol, computer a can send a request to computer b and computer b can respond, but computer b cannot send a request to computer a. Hence the reason computer a must continually poll computer b in order for computer b to be able to respond within a reasonable amount of time to a certain change.
So Jenk's technicality is about as close to being the most relevant to this situation as is possible.
Cheers
ps. Josh, that doesn't mean I disagree with ya, it's just that you're getting into the weeds to a point that it's not as relevant to this situation. For instance, persistent connections are a whole heck of a lot more efficient than polling. Your technicality abstracts that away and pretty much says there is no difference on the grounds that "listening" is never really a reality, so everything polls when you look down to a deep enough level.
Re: How to get informed Clients Disconnected from the Server
Actually, there is a technique for server-based push requests and it's called comet - http://en.wikipedia.org/wiki/Comet_%28programming%29
Re: How to get informed Clients Disconnected from the Server
Does it really? The business requirement was to disconnect the client from the server when the server decides. A periodic polling accomplishes that. It is for the most part irrelevant in what way it accomplishes that.PHPHorizons wrote:In this case, josh's level of being technical goes to an extreme and begins to lose touch with the actual substance of the problem here.
If the business requirement was to send a message with a minimal amount of latency, then a polling based solution may no longer be applicable. (Eg if we were building a massive RPG style game). In this case it is a web page with a few hundred to few thousand users that we need to simply enumerate a few times a minute.
I guess the RFC spells out exactly where they want the line drawn though:
"According to RFC 2616 (page 47), a single-user client should not maintain more than 2 connections with any server or proxy"
But even web apps like gmail have 100s of ajax requests going on a minute, and seem to scale & work fine.
- PHPHorizons
- Forum Contributor
- Posts: 175
- Joined: Mon Sep 14, 2009 11:38 pm
Re: How to get informed Clients Disconnected from the Server
That's what I was talking about.Josh wrote:Technically nothing software related listens
Re: How to get informed Clients Disconnected from the Server
I was only pointing out that it doesn't matter what it "technically" does or does not do, as long as it achieves the goal (the substance of the problem as you put it). I think you entirely missed my point because we are both arguing the same thing.