summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/peer.tcl10
-rw-r--r--lib/process.tcl10
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/peer.tcl b/lib/peer.tcl
index ca9c473a..e46017a0 100644
--- a/lib/peer.tcl
+++ b/lib/peer.tcl
@@ -1,8 +1,11 @@
+lappend auto_path "./vendor"
+package require websocket
+
proc ::peer {node} {
namespace eval Peers::$node {
proc setupSock {} {
variable node
- puts "sharer: Trying to connect to: ws://$node:4273/ws"
+ puts "peer: Trying to connect to: ws://$node:4273/ws"
variable sock [::websocket::open "ws://$node:4273/ws" [namespace code handleWs]]
}
proc handleWs {sock type msg} {
@@ -26,10 +29,7 @@ proc ::peer {node} {
::websocket::send $sock text $msg
}
- proc init {n} {
- variable node $n
- setupSock
- }
+ proc init {n} { variable node $n; setupSock }
init
} $node
}
diff --git a/lib/process.tcl b/lib/process.tcl
index 1bca66da..5208384b 100644
--- a/lib/process.tcl
+++ b/lib/process.tcl
@@ -4,15 +4,16 @@ set ::processPrelude {
try $body
after $ms [list after idle [namespace code [info level 0]]]
}
- # TODO: do a socket connection to localhost
-
+
+ source "lib/peer.tcl"
+ peer "localhost"
}
proc On-process {name body} {
namespace eval ::Processes::$name {}
set ::Processes::${name}::name $name
set ::Processes::${name}::body $body
- set ::Processes::${name}::this [uplevel {set this}]
+ set ::Processes::${name}::this [uplevel {expr {[info exists this] ? $this : "<unknown>"}}]
namespace eval ::Processes::$name {
variable tclfd [file tempfile tclfile tclfile.tcl]
puts $tclfd [join [list $::processPrelude $body] "\n"]; close $tclfd
@@ -28,6 +29,7 @@ proc On-process {name body} {
variable log
if {[gets $stdio line] >= 0} {
lappend log $line
+ puts "$name: $line"
Retract process $name has standard output log /l/
Assert process $name has standard output log $log
Step
@@ -36,7 +38,7 @@ proc On-process {name body} {
fconfigure $stdio -blocking 0 -buffering line
fileevent $stdio readable [namespace code handleReadable]
- if {[info exists this]} {
+ if {$this ne "<unknown>"} {
Assert $this is running process $name
}