[REBOL] Rugby p2p chat sample
From: koopmans::itr::ing::nl at: 22-Nov-2001 12:59
Hi Petr,
As promised here it is....
Two files, node1 and node2, cut 'n paste, run them on your local machine. Of
course you can use /http or whatever, merely demonstrating. But in the end it
still *is* a network config problem for ingoing/outgoing connections, as with
IRC.
Don't forget to put rugby.r in the same directory!
--Maarten
**** Node 1
REBOL []
do %rugby.r
l: layout
[
across
Title "Node 1" return
h1 "Node 1" return
a1: area return
h2 "Node 2" return
a2: area return
button "Send"
[ init-nodes node2/send-msg a1/text]
]
imports: off
init-nodes: does
[
if not imports
[ node2: context get-rugby-service tcp://localhost:8003 imports: on]
]
send-msg: func [ s [string!]][a2/text: s show a2]
view/new l
serve [send-msg]
***** Node 2
REBOL []
do %rugby.r
l: layout
[
across
Title "Node 2" return
h1 "Node 1" return
a1: area return
h2 "Node 2" return
a2: area return
button "Send"
[ init-nodes node1/send-msg a2/text]
]
imports: off
init-nodes: does
[
if not imports
[ node1: context get-rugby-service tcp://localhost:8001 imports: on]
]
send-msg: func [ s [string!]][a1/text: s show a1]
view/new l
serve/with/with-http [send-msg] tcp://:8003 tcp://:8004