REBOL [ Title: "Broadcast Console" Purpose: { To broadcast what you type on the console to a number of clients, that basically view what you are doing. } Author: "Gabriele Santilli" EMail: giesse@rebol.it File: %broadcast-console.r License: { Copyright (C) 2003 Gabriele Santilli This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. http://www.gnu.org/copyleft/gpl.html } Date: 29-Sep-2004 Version: 1.2.0 ; majorv.minorv.status ; status: 0: unfinished; 1: testing; 2: stable History: [ 28-Sep-2004 1.1.0 "History start" 29-Sep-2004 1.2.0 "Allows watching the broadcaster's console" ] ] dests: [ ] old-input: system/ports/input old-output: system/ports/output bcast: make Root-Protocol [ open: func [port] [ ;print "open" ] close: func [port] [ ;print "close" ] get-sub-port: func [port] [ old-input ] read: func [port buffer /local len] [ ;?? buffer len: read-io old-input buffer port/state/num broadcast buffer len ] write: func [port data /local len] [ ;?? buffer len: write-io old-output data port/state/num broadcast data len ] net-utils/net-install 'bcast self 0 ] broadcast: func [data] [ foreach port dests [ insert port data ] ] start-broadcasting: does [ listen: open/binary/direct tcp://:10000 system/ports/input: open/direct/read/lines bcast:// system/ports/output: open/direct/write/with bcast:// CRLF ] accept: does [ insert tail dests first listen insert old-output "^/[new watcher]^/" ] watch: func [url] [ port: open/direct/no-wait url forever [wait port prin copy port] ]