How can a server communiate with two clients at once (JavaScript, HTML, PHP)? -
i got assignment , use www technology html, javascript, php etc. i'm sorry haven't studied of these technologies. therefore took few tutorials , skimmed through them searching answers.
i found solutions many problems 1 problem yet unsolved. this:
i want 2 clients communicate through server assignment. 1 send message, server processes , forwards next.
none of php tutorials showed me anyway of doing this. of them talked of communication between 1 client server.
please help. show me way this. thanks.
currently, without reverting cutting-edge (and possibly hacky/unreliable) techniques, php server cannot initiate communications page you've loaded web browser. result of way http protocol works.
one way solve polling on "receiving" end data. publish-subscribe pattern.
one way be:
- one client sends data server using http request (xhr aka ajax) specifying target data (the other client).
- the server stores data in persistent storage (local file, database, etc).
- the second client periodically sends request server asking if there's new data consume. can done using setinterval , xhr in javascript.
i suggest take at:
http://en.wikipedia.org/wiki/publish/subscribe
and also, cutting edge way this, check out socket.io:
Comments
Post a Comment