Hi Nick. I've gone back to your original question. The "right" way to do
this undoubtedly involves sockets, which in turn requires a private web
server (or very permissive web hosting company), so isn't readily
available to most of us.
But there is a way to do it using only simple ordinary Web server and
client features. I've done it as a proof of concept using on-rev, but
the server part of it is *so* simple I could probably do it in php if I
had to.
Theory (simple web-based chat application)
Client
The client (which can be found at
http://www.tweedly.org/async_web_chat_released.rev ) uses "load url" to
request the latest update from the chat server. If it times out, it
simply tries again :-0 If it receives data, it appends that data to the
scrolling text window, and repeats forever (or until stopped).
The client can also "say" something to the server.
Server (is even more simple - see the text of the scripts below)
saysomething.irev
takes a single parameter (i.e. tweedly.org/saysomething.irev?say=the
text ) and appends this to a file (called, imaginatively, my.txt)
listen.irev
takes a single parameter (i.e. tweedly.org/listen.irev?lastline=23 )
which is the last line of the file which that client has already
received. It then checks if the file has grown longer - in which case it
sends the additional lines to the client. Otherwise, it waits for 100
msec, and then tries again.
Eventually, if there is no new data, the client will time out - then it
does an "unload url" to cancel the request, and tries again.
The nice thing is you can test and debug this with a browser - try
www.tweedly.org/listen.irev?lastline=1
http://www.tweedly.org/saysomething.irev?say=ALEX:says%20this
www.tweedly.org/listen.irev?lastline=1
saysomething.irev
<?rev
set the errormode to inline
put $_GET["say"] into tSay
open file "my.txt" for text append
put "open result = " & the result
write tSay & CR to file "my.txt"
put URL("file:my.txt") into t
put the number of lines in t
?>
listen.irev
<?rev
put $_GET["lastline"] into tLast
repeat with i = 1 to 100
put URL ("file:my.txt") into tData
if the number of lines in tData > tLast then
delete line 1 to tLast in tData
put tData
exit repeat
end if
wait for 100 millisec
put empty into tData
end repeat
if tData is empty then
put "no new data"
end if
?>
NOTE - I do not recommedn this if you intend to scle in any way, but for
small number of users, with small data rates this should be just fine.
-- Alex.
Nicolas Cueto wrote:
Where in the Rev documentation (or sample stacks?) should I be looking to
learn how to do the following?
Given 6 identical standalones running of 6 computers all internet connected,
I want an event X triggered on any one of those computers to be immediately
relayed to the other 5 computers.
An example of what I'm planning is a multiple-choice quiz. As soon as the
contestant on computer A buzzes in, her choice should display immediately on
the other contestants' computers B thru F.
My guess is that to enable stacks to "wait", sockets will be involved.
I'm also guessing that these are the three Rev elements (one local, two
server-side) I'll nee for this multi-player multiple-choice quiz standalone:
1) the stack itself
2) a Rev cgi-script to co-ordinate the interaction between standalones
3) an SQL table to store or temporarily hold game-related variables
Thank you.
--
Nicolas Cueto
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution