1 # vim: ft=tcl foldmarker=<<<,>>>
3 class tlc
::SessionCon {
5 constructor
{parms a_con cl_ip cl_port
} {tlc
::Con::constructor $parms $a_con $cl_ip $cl_port} {}
12 method attach_to_session
{sessionid
}
13 method get_new_session
{}
14 method setvar
{varname value
}
15 method getvar
{varname
}
24 body tlc
::SessionCon::constructor {parms a_con cl_ip cl_port
} { #<<<1
27 if {$sessionkey==""} {
30 attach_to_session
$sessionkey
32 log debug
"Session-enabled connection active."
35 body tlc
::SessionCon::session_ref {} {
39 body tlc
::SessionCon::attach_to_session {$skey} { #<<<1
40 if {[info exists sessions
($skey)]} {
41 if {[info exists
$sessions($skey)]} {
42 # this is a valid session that we may attach to
43 set session
$sessions($skey)
47 # the session has timed out -- remove the reference and report unsuccessful connection
48 array unset sessions
$skey
58 body tlc
::SessionCon::get_new_session {} { #<<<1
59 log debug
"requesting new session object"
60 set session
[Sessionobj
::#auto -client_ip $client_ip]
61 set sessionkey
[$session cget
-sessionkey]
62 log debug
"sessionkey is: $sessionkey"
63 set sessions
($sessionkey) $session
64 log debug
"sessions($sessionkey) is: $session"
68 body tlc
::SessionCon::setvar {varname value
} { #<<<1
69 log debug
"entering setvar for sessioncon, varname: $varname; varval: $value"
70 log debug
"attempting to use session: $session"
71 if {[info exists sessions
($sessionkey)]} {
72 log debug
"session exists; requesting setvar"
73 return [$session setvar
$varname $value]
75 log debug
"no session found: returning empty"
80 body tlc
::SessionCon::getvar {varname
} { #<<<1
81 log debug
"entering getvar for sessioncon"
82 if {[info exists sessions
($sessionkey)]} {
83 log debug
"session exists; asking session for variable"
84 return [$session getvar
$varname]
90 body tlc
::SessionCon::destructor {} { #<<<1