From: Matt S Trout Date: Sun, 9 Sep 2012 16:34:44 +0000 (+0000) Subject: ten::handle class X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2cecba5d55ca5249b4c3bbc4b388ddf85d739f72;p=scpubgit%2FTenDotTcl.git ten::handle class --- diff --git a/t/connection.t b/t/connection.t index ab4397b..7c28bc7 100644 --- a/t/connection.t +++ b/t/connection.t @@ -39,16 +39,14 @@ set ortestdata [[$conn send call {*}[jws class_call_handler 0 call ORTestClass n set ortestoid [lindex $ortestdata 0 1] -proc ortest {args} { - return [[$::conn send call {*}[jws $::ortestoid 0 {*}$args]] await_get] -} +ten::handle ortest -id $ortestoid -connection $conn -cmp_ok != [pid] [ortest pid] "pid is different on the other side" +cmp_ok != [pid] [ortest call pid] "pid is different on the other side" -is [ortest counter] 0 "Counter at 0" +is [ortest call counter] 0 "Counter at 0" -is [ortest increment] 1 "Incrememt to 1" +is [ortest call increment] 1 "Incrememt to 1" -is [ortest counter] 1 "Counter at 1" +is [ortest call counter] 1 "Counter at 1" done_testing diff --git a/ten/ten.tcl b/ten/ten.tcl index 3abe931..988915d 100644 --- a/ten/ten.tcl +++ b/ten/ten.tcl @@ -249,4 +249,17 @@ snit::type ten::read_channel { } } +snit::type ten::handle { + option -connection + option -id + + method call {name args} { + return [[$self start $name {*}$args] await_get] + } + + method start {name args} { + $options(-connection) send call [json::write string $options(-id)] 0 [json::write string $name] {*}$args + } +} + package provide ten 0.0.1