1 import TCP
2 import TCP/Server
3
4 Class TCP/DegasControl -superclass TCP
5
6 TCP/DegasControl public init {server host port aglp} {
7
8 # agent_ is the DegasAgent object that control the degas service.
9 # it has to support all callbacks and a "stop_service" method.
10
11 $self instvar server_ host_ port_ aglp_
12 set server_ $server
13 set host_ $host
14 set port_ $port
15 set aglp_ $aglp
16 $self next
17 }
18
19 TCP/DegasControl public close {} {
20 $self instvar server_
21 $server_ close_channel
22 $self next
23 }
24
25 TCP/DegasControl public recv {s} {
26 $self [lindex $s 0]_callback [lrange $s 1 end]
27 }
28
29 TCP/DegasControl private deglet_callback {argv} {
30 $self instvar aglp_ host_ port_
31 set pid [lindex $argv 0]
32 set recv_session_spec [lindex $argv 1]
33 set argv [lrange $argv 2 end]
34 regsub -all "::" $argv "\n" prog
35 $aglp_ parse_program $host_ $pid $prog
36 $aglp_ start_service $host_ $pid $recv_session_spec
37 }
38
39
40 TCP/DegasControl private get_callback {argv} {
41 scan $argv "%s %d" client_addr pid
42 $self instvar aglp_
43 set program [$aglp_ get_program $client_addr $pid]
44 regsub -all "\n" $program "::" prog
45 $self send "handoff $client_addr $pid $prog\n"
46 }
47
48
49 TCP/DegasControl private mouse_click_callback {argv} {
50 $self instvar server_
51 set agent [$server_ set agent_]
52 set x [lindex $argv 0]
53 set y [lindex $argv 1]
54 $agent mouse_click_callback $x $y
55 }
56
57 Class TCP/Server/DegasControl -superclass TCP/Server
58
59 TCP/Server/DegasControl public init { aglp } {
60
61 $self instvar num_of_channel_ aglp_
62 set num_of_channel_ 0
63 set aglp_ $aglp
64 $self set agent_ { }
65 $self next
66 }
67
68 TCP/Server/DegasControl public accept {chan host port} {
69 $self create_channel $chan $host $port
70 }
71
72 TCP/Server/DegasControl public create_channel {chan host port} {
73 $self instvar num_of_channel_ aglp_ agent_
74 set tcp [new TCP/DegasControl $self $host $port $aglp_]
75 $tcp open $chan
76 incr num_of_channel_
77 return $tcp
78 }
79
80 TCP/Server/DegasControl public close_channel {} {
81 $self instvar num_of_channel_
82 incr num_of_channel_ -1
83 }
84
85 TCP/Server/DegasControl public close {} {
86 $self next
87 }
88
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.