1 # vim: foldmarker=<<<,>>>
6 constructor
{parms a_con cl_ip cl_port
} {}
14 method
send {res id msg
}
15 method parse_tabular
{data
}
16 method compile_tabular
{data
}
22 variable current_protocol
"default"
25 method prot_default
{op args
}
30 body tlc
::Con::constructor {parms a_con cl_ip cl_port
} { #<<<1
31 array set protocols
{}
35 if {![info exists server
]} {
36 error "Must set -server"
41 array set protocols
[$server get_protocols
]
43 fconfigure $con -blocking 1 -translation binary -encoding binary
44 fileevent $con readable
[code
$this readable
]
48 body tlc
::Con::destructor {} { #<<<1
50 invoke_handlers
close $this
51 uplevel #0 $close_cb [list $this]
55 body tlc
::Con::readable {} { #<<<1
56 if {![info exists protocols
($current_protocol)]} return
57 set res
[uplevel #0 $protocols($current_protocol) [list server_read $con]]
64 set tag
[lindex $res 0]
65 set subcmd
[lindex $res 1]
66 set id
[lindex $res 2]
67 set dat
[lindex $res 3]
68 if {$tag == "set_protocol"} {
69 set current_protocol
$subcmd
73 uplevel #0 $newmsg_cb [list $this $tag $subcmd $id $dat]
77 body tlc
::Con::send {res id msg
} { #<<<1
78 if {![info exists protocols
($current_protocol)]} {
79 error "No handler for currently registered protocol"
81 uplevel #0 $protocols($current_protocol) \
82 [list server_write
$con $res $id $msg]
86 body tlc
::Con::parse_tabular {data
} { #<<<1
87 if {![info exists protocols
($current_protocol)]} {
88 error "No handler for currently registered protocol"
90 return [uplevel #0 $protocols($current_protocol) \
91 [list parse_tabular
$data]]
95 body tlc
::Con::compile_tabular {data
} { #<<<1
96 if {![info exists protocols
($current_protocol)]} {
97 error "No handler for currently registered protocol"
99 return [uplevel #0 $protocols($current_protocol) \
100 [list compile_tabular
$data]]