| 1 | package POE::XUL::Controler; | ||||||||||||||
| 2 | # $Id: Controler.pm 1566 2010-11-03 03:13:32Z fil $ | ||||||||||||||
| 3 | # | ||||||||||||||
| 4 | # Copyright Philip Gwyn / Awalé 2007-2010. All rights reserved. | ||||||||||||||
| 5 | # | ||||||||||||||
| 6 | |||||||||||||||
| 7 | 14 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 14 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 14 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 14 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 14 | ▶ | use POE::Kernel; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 14 | ▶ | use POE::XUL::ChangeManager; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 14 | ▶ | use POE::XUL::Event; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 14 | ▶ | use POE::XUL::Logging; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 14 | ▶ | use Scalar::Util qw( weaken ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | |||||||||||||||
| 18 | 14 | ▶ | use constant DEBUG => 0; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | |||||||||||||||
| 20 | 14 | our $VERSION = '0.0600'; | |||||||||||||
| 21 | |||||||||||||||
| 22 | ############################################################## | ||||||||||||||
| 23 | sub new | ||||||||||||||
| 24 | { | ||||||||||||||
| 25 | 6 | ▶ | my( $package, $timeout, $apps ) = @_; | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 26 | 6 | my $self = bless { | |||||||||||||
| 27 | sessions => {}, | ||||||||||||||
| 28 | timeout => $timeout, | ||||||||||||||
| 29 | apps => $apps, | ||||||||||||||
| 30 | events => {} | ||||||||||||||
| 31 | }, $package; | ||||||||||||||
| 32 | 6 | return $self; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | ############################################################## | ||||||||||||||
| 36 | sub build_event | ||||||||||||||
| 37 | { | ||||||||||||||
| 38 | 0 | ▶ | my( $self, $event_name, $CM, $resp, $req ) = @_; | ||||||||||||
|
Subroutine
build_event: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 39 | 0 | my $event = POE::XUL::Event->new( $event_name, $CM, $resp ); | |||||||||||||
| 40 | |||||||||||||||
| 41 | # Keep a weak reference so we can cancel the event if needs be | ||||||||||||||
| 42 | 0 | my $r = 0+$req; | |||||||||||||
| 43 | 0 | $self->{events}{$r} = $event; | |||||||||||||
| 44 | 0 | weaken( $self->{events}{$r} ); | |||||||||||||
| 45 | 0 | DEBUG and xwarn "BUILD r=$r event=$event"; | |||||||||||||
| 46 | |||||||||||||||
| 47 | 0 | return $event; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | ############################################################## | ||||||||||||||
| 51 | sub build_change_manager | ||||||||||||||
| 52 | { | ||||||||||||||
| 53 | 0 | ▶ | my( $self ) = @_; | ||||||||||||
|
Subroutine
build_change_manager: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 54 | |||||||||||||||
| 55 | 0 | return POE::XUL::ChangeManager->new(); | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | |||||||||||||||
| 58 | |||||||||||||||
| 59 | |||||||||||||||
| 60 | |||||||||||||||
| 61 | ############################################################## | ||||||||||||||
| 62 | # Does a given session ID exist? | ||||||||||||||
| 63 | sub exists | ||||||||||||||
| 64 | { | ||||||||||||||
| 65 | 0 | ▶ | my( $self, $SID ) = @_; | ||||||||||||
|
Subroutine
exists: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 66 | 0 | return exists $self->{sessions}{ $SID }; | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | |||||||||||||||
| 69 | ############################################################## | ||||||||||||||
| 70 | # How many sessions currently exist | ||||||||||||||
| 71 | sub count | ||||||||||||||
| 72 | { | ||||||||||||||
| 73 | 0 | ▶ | my( $self ) = @_; | ||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 74 | 0 | return 0 + keys %{ $self->{sessions} }; | |||||||||||||
| 75 | } | ||||||||||||||
| 76 | |||||||||||||||
| 77 | |||||||||||||||
| 78 | ############################################################## | ||||||||||||||
| 79 | # A new session has been created | ||||||||||||||
| 80 | sub register | ||||||||||||||
| 81 | { | ||||||||||||||
| 82 | 0 | ▶ | my( $self, $SID, $session, $CM ) = @_; | ||||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 83 | |||||||||||||||
| 84 | 0 | DEBUG and xdebug "register SID=$SID"; | |||||||||||||
| 85 | # TODO make sure the session has the SID as an alias? | ||||||||||||||
| 86 | 0 | $self->{sessions}{ $SID } = { | |||||||||||||
| 87 | session => $session->ID, | ||||||||||||||
| 88 | CM => $CM | ||||||||||||||
| 89 | }; | ||||||||||||||
| 90 | 0 | $self->keepalive( $SID ); | |||||||||||||
| 91 | } | ||||||||||||||
| 92 | |||||||||||||||
| 93 | ############################################################## | ||||||||||||||
| 94 | # A session has been shutdown | ||||||||||||||
| 95 | sub unregister | ||||||||||||||
| 96 | { | ||||||||||||||
| 97 | 0 | ▶ | my( $self, $SID ) = @_; | ||||||||||||
|
Subroutine
unregister: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 98 | 0 | ▶ | return unless $self->{sessions}{ $SID }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 99 | 0 | DEBUG and xdebug "Unregister SID=$SID"; | |||||||||||||
| 100 | 0 | my $details = delete $self->{sessions}{ $SID }; | |||||||||||||
| 101 | |||||||||||||||
| 102 | 0 | my $tid = $details->{timeout_id}; | |||||||||||||
| 103 | 0 | my $session = $details->{session}; | |||||||||||||
| 104 | 0 | my $CM = $details->{CM}; | |||||||||||||
| 105 | 0 | ▶ | if( $tid ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 106 | 0 | $poe_kernel->alarm_remove( $tid ); | |||||||||||||
| 107 | } | ||||||||||||||
| 108 | 0 | $CM->dispose; | |||||||||||||
| 109 | 0 | $poe_kernel->post( $session, 'shutdown', $SID ); # TODO use alias $SID | |||||||||||||
| 110 | } | ||||||||||||||
| 111 | |||||||||||||||
| 112 | ############################################################## | ||||||||||||||
| 113 | sub keepalive | ||||||||||||||
| 114 | { | ||||||||||||||
| 115 | 0 | ▶ | my( $self, $SID ) = @_; | ||||||||||||
|
Subroutine
keepalive: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 116 | 0 | ▶ | return unless $self->{sessions}{ $SID }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 117 | 0 | my $tid = $self->{sessions}{$SID}{timeout_id}; | |||||||||||||
| 118 | 0 | ▶ | if( $tid ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 119 | |||||||||||||||
| 120 | 0 | $poe_kernel->delay_adjust( $tid, $self->{timeout} ); | |||||||||||||
| 121 | 0 | DEBUG and | |||||||||||||
| 122 | xdebug "timeout for $SID: tid=$self->{sessions}{$SID}{timeout_id} timeout=$self->{timeout}"; | ||||||||||||||
| 123 | } | ||||||||||||||
| 124 | else { | ||||||||||||||
| 125 | # session_timeout is defined in POE::Component::XUL | ||||||||||||||
| 126 | $self->{sessions}{ $SID }{timeout_id} = | ||||||||||||||
| 127 | $poe_kernel->delay_set( 'session_timeout', | ||||||||||||||
| 128 | $self->{timeout}, | ||||||||||||||
| 129 | 0 | $SID ); | |||||||||||||
| 130 | 0 | DEBUG and | |||||||||||||
| 131 | xdebug "timeout for $SID: tid=$self->{sessions}{$SID}{timeout_id} timeout=$self->{timeout}"; | ||||||||||||||
| 132 | } | ||||||||||||||
| 133 | } | ||||||||||||||
| 134 | |||||||||||||||
| 135 | |||||||||||||||
| 136 | ############################################################## | ||||||||||||||
| 137 | # Find the constructor for a package | ||||||||||||||
| 138 | sub package_ctor | ||||||||||||||
| 139 | { | ||||||||||||||
| 140 | 0 | ▶ | my( $self, $package ) = @_; | ||||||||||||
|
Subroutine
package_ctor: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 141 | |||||||||||||||
| 142 | 0 | ▶ | confess "No package" unless $package; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 143 | 0 | return $package->can( 'spawn' ); | |||||||||||||
| 144 | } | ||||||||||||||
| 145 | |||||||||||||||
| 146 | ############################################################## | ||||||||||||||
| 147 | # Spawn a component from a package | ||||||||||||||
| 148 | sub package_build | ||||||||||||||
| 149 | { | ||||||||||||||
| 150 | 0 | ▶ | my( $self, $package ) = @_; | ||||||||||||
|
Subroutine
package_build: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 151 | 0 | my $ctor = $self->package_ctor( $package ); | |||||||||||||
| 152 | 0 | ▶ | unless( $ctor ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 153 | return sub { | ||||||||||||||
| 154 | 0 | ▶ | my( $event ) = @_; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 155 | 0 | $event->response->content( "Can't build an application from $package" ); | |||||||||||||
| 156 | 0 | $event->response->code( 500 ); | |||||||||||||
| 157 | 0 | }; | |||||||||||||
| 158 | } | ||||||||||||||
| 159 | 0 | ▶ | return sub { $ctor->( $package, @_ ) }; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 160 | } | ||||||||||||||
| 161 | |||||||||||||||
| 162 | |||||||||||||||
| 163 | ############################################################## | ||||||||||||||
| 164 | sub boot | ||||||||||||||
| 165 | { | ||||||||||||||
| 166 | 0 | ▶ | my( $self, $req, $resp ) = @_; | ||||||||||||
|
Subroutine
boot: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 167 | 0 | my $app = $req->param( 'app' ); | |||||||||||||
| 168 | 0 | ▶ | unless( $app ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 169 | 0 | xlog "Controler: Request must have application name"; | |||||||||||||
| 170 | 0 | return "Controler: Request must have application name"; | |||||||||||||
| 171 | } | ||||||||||||||
| 172 | 0 | my $A = $self->{apps}{$app}; | |||||||||||||
| 173 | |||||||||||||||
| 174 | 0 | ▶ | unless( $A ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 175 | 0 | xlog "Unknown application: $app"; | |||||||||||||
| 176 | 0 | return "Application inconnue : $app"; | |||||||||||||
| 177 | } | ||||||||||||||
| 178 | |||||||||||||||
| 179 | 0 | ▶ | unless( ref $A ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 180 | 0 | $A = $self->package_build( $A ); | |||||||||||||
| 181 | } | ||||||||||||||
| 182 | |||||||||||||||
| 183 | # use Data::Dumper; | ||||||||||||||
| 184 | # xlog "A=", Dumper $A; | ||||||||||||||
| 185 | 0 | my $CM = $self->build_change_manager(); | |||||||||||||
| 186 | |||||||||||||||
| 187 | 0 | my $event = $self->build_event( 'boot', $CM, $resp, $req ); | |||||||||||||
| 188 | 0 | $event->__init( $req ); | |||||||||||||
| 189 | $event->coderef( | ||||||||||||||
| 190 | sub { | ||||||||||||||
| 191 | 0 | ▶ | my( $event ) = @_; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 192 | 0 | my $SID = $self->make_session_id; | |||||||||||||
| 193 | 0 | $event->SID( $SID ); | |||||||||||||
| 194 | 0 | $event->CM->SID( $SID ); | |||||||||||||
| 195 | 0 | my $session = $A->( $event, $app ); | |||||||||||||
| 196 | 0 | $self->register( $SID, $session, $event->CM ); | |||||||||||||
| 197 | 0 | $event->defer; | |||||||||||||
| 198 | 0 | $poe_kernel->post( $SID, 'boot', $event, $app ); | |||||||||||||
| 199 | } | ||||||||||||||
| 200 | 0 | ); | |||||||||||||
| 201 | |||||||||||||||
| 202 | 0 | $self->xul_request( $event ); | |||||||||||||
| 203 | 0 | return; | |||||||||||||
| 204 | } | ||||||||||||||
| 205 | |||||||||||||||
| 206 | ############################################################## | ||||||||||||||
| 207 | sub close | ||||||||||||||
| 208 | { | ||||||||||||||
| 209 | 0 | ▶ | my( $self, $SID, $req, $resp ) = @_; | ||||||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 210 | |||||||||||||||
| 211 | 0 | my $S = $self->{sessions}{ $SID }; | |||||||||||||
| 212 | 0 | ▶ | die "Can't find session $SID" unless $SID; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 213 | |||||||||||||||
| 214 | 0 | my $event = $self->build_event( 'close', $S->{CM}, $resp, $req ); | |||||||||||||
| 215 | $event->coderef( | ||||||||||||||
| 216 | sub { | ||||||||||||||
| 217 | 0 | ▶ | xlog "Close $SID"; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 218 | # TODO : use alias $SID | ||||||||||||||
| 219 | 0 | my $session = $poe_kernel->ID_id_to_session( $S->{session} ); | |||||||||||||
| 220 | 0 | $poe_kernel->signal( $session, 'UIDESTROY' ); | |||||||||||||
| 221 | 0 | $self->unregister( $SID ); | |||||||||||||
| 222 | } | ||||||||||||||
| 223 | 0 | ); | |||||||||||||
| 224 | |||||||||||||||
| 225 | 0 | $self->xul_request( $event ); | |||||||||||||
| 226 | 0 | return; | |||||||||||||
| 227 | } | ||||||||||||||
| 228 | |||||||||||||||
| 229 | ############################################################## | ||||||||||||||
| 230 | sub connect | ||||||||||||||
| 231 | { | ||||||||||||||
| 232 | 0 | ▶ | my( $self, $SID, $req, $resp ) = @_; | ||||||||||||
|
Subroutine
connect: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 233 | |||||||||||||||
| 234 | 0 | my $S = $self->{sessions}{ $SID }; | |||||||||||||
| 235 | 0 | ▶ | die "Can't find session $SID" unless $SID; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 236 | |||||||||||||||
| 237 | 0 | my $event = $self->build_event( 'connect', $S->{CM}, $resp, $req ); | |||||||||||||
| 238 | 0 | $event->__init( $req ); | |||||||||||||
| 239 | |||||||||||||||
| 240 | $event->coderef( sub { | ||||||||||||||
| 241 | 0 | ▶ | $event->defer; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 242 | 0 | $poe_kernel->post( $SID, 'connect', $event ); | |||||||||||||
| 243 | 0 | } ); | |||||||||||||
| 244 | 0 | $self->xul_request( $event ); | |||||||||||||
| 245 | 0 | return; | |||||||||||||
| 246 | } | ||||||||||||||
| 247 | |||||||||||||||
| 248 | ############################################################## | ||||||||||||||
| 249 | sub disconnect | ||||||||||||||
| 250 | { | ||||||||||||||
| 251 | 0 | ▶ | my( $self, $SID, $req, $resp ) = @_; | ||||||||||||
|
Subroutine
disconnect: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 252 | |||||||||||||||
| 253 | 0 | my $S = $self->{sessions}{ $SID }; | |||||||||||||
| 254 | 0 | ▶ | die "Can't find session $SID" unless $SID; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 255 | |||||||||||||||
| 256 | 0 | my $event = $self->build_event( 'disconnect', $S->{CM}, $resp, $req ); | |||||||||||||
| 257 | 0 | $event->__init( $req ); | |||||||||||||
| 258 | |||||||||||||||
| 259 | $event->coderef( sub { | ||||||||||||||
| 260 | 0 | ▶ | $event->defer; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 261 | 0 | $poe_kernel->post( $SID, 'disconnect', $event ); | |||||||||||||
| 262 | 0 | } ); | |||||||||||||
| 263 | 0 | $self->xul_request( $event ); | |||||||||||||
| 264 | 0 | return; | |||||||||||||
| 265 | } | ||||||||||||||
| 266 | |||||||||||||||
| 267 | ############################################################## | ||||||||||||||
| 268 | sub request | ||||||||||||||
| 269 | { | ||||||||||||||
| 270 | 0 | ▶ | my ( $self, $SID, $event_type, $req, $resp ) = @_; | ||||||||||||
|
Subroutine
request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 271 | |||||||||||||||
| 272 | 0 | my $S = $self->{sessions}{ $SID }; | |||||||||||||
| 273 | 0 | ▶ | die "Can't find session $SID" unless $SID; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 274 | |||||||||||||||
| 275 | 0 | my $event = $self->build_event( $event_type, $S->{CM}, $resp, $req ); | |||||||||||||
| 276 | 0 | $event->__init( $req ); | |||||||||||||
| 277 | |||||||||||||||
| 278 | 0 | $self->xul_request( $event ); | |||||||||||||
| 279 | } | ||||||||||||||
| 280 | |||||||||||||||
| 281 | |||||||||||||||
| 282 | ############################################################## | ||||||||||||||
| 283 | # Standard XUL request (Click / Change / etc ) | ||||||||||||||
| 284 | sub xul_request | ||||||||||||||
| 285 | { | ||||||||||||||
| 286 | 0 | ▶ | my( $self, $event ) = @_; | ||||||||||||
|
Subroutine
xul_request: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 287 | |||||||||||||||
| 288 | 0 | $event->done( 1 ); | |||||||||||||
| 289 | 0 | $event->run(); | |||||||||||||
| 290 | |||||||||||||||
| 291 | 0 | DEBUG and xdebug "Request done"; | |||||||||||||
| 292 | 0 | ▶ | if( $event->is_flushed ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 293 | # User code might have already flushed everything | ||||||||||||||
| 294 | 0 | DEBUG and xdebug "Request already flushed"; | |||||||||||||
| 295 | } | ||||||||||||||
| 296 | elsif( $event->done ) { | ||||||||||||||
| 297 | 0 | DEBUG and xdebug "Response now"; | |||||||||||||
| 298 | 0 | $event->flush; | |||||||||||||
| 299 | } | ||||||||||||||
| 300 | else { | ||||||||||||||
| 301 | # User code wants us to wait | ||||||||||||||
| 302 | 0 | DEBUG and xdebug "Defered response"; | |||||||||||||
| 303 | # User code will then call $event->finish when the time is right | ||||||||||||||
| 304 | } | ||||||||||||||
| 305 | 0 | return 1; | |||||||||||||
| 306 | } | ||||||||||||||
| 307 | |||||||||||||||
| 308 | ############################################################## | ||||||||||||||
| 309 | ## Cancel a request. This happens on browser disconnect | ||||||||||||||
| 310 | sub cancel | ||||||||||||||
| 311 | { | ||||||||||||||
| 312 | 0 | ▶ | my( $self, $request ) = @_; | ||||||||||||
|
Subroutine
cancel: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 313 | |||||||||||||||
| 314 | 0 | my $r = 0+$request; | |||||||||||||
| 315 | 0 | my $event = $self->{events}{ $r }; | |||||||||||||
| 316 | 0 | ▶ | unless( $event ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 317 | 0 | ▶ | if( $request->method ne 'DISCONNECT' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 318 | 0 | xlog "FAILURE! I no longer have an event for $request ", 0+$request; | |||||||||||||
| 319 | } | ||||||||||||||
| 320 | 0 | return; | |||||||||||||
| 321 | } | ||||||||||||||
| 322 | |||||||||||||||
| 323 | 0 | my $SID = $event->SID; | |||||||||||||
| 324 | 0 | my $S = $self->{sessions}{ $SID }; | |||||||||||||
| 325 | 0 | ▶ | unless( $SID ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 326 | 0 | xwarn "Can't find session $SID"; | |||||||||||||
| 327 | 0 | return; | |||||||||||||
| 328 | } | ||||||||||||||
| 329 | |||||||||||||||
| 330 | DEBUG and | ||||||||||||||
| 331 | 0 | xwarn "CANCEL r=$r event=$event SID=$SID"; | |||||||||||||
| 332 | |||||||||||||||
| 333 | 0 | $event->cancel; | |||||||||||||
| 334 | # TODO : do I need to set a flag on the CM? | ||||||||||||||
| 335 | } | ||||||||||||||
| 336 | |||||||||||||||
| 337 | ############################################################## | ||||||||||||||
| 338 | ## Generate an unguessable session ID. | ||||||||||||||
| 339 | ## Though unguessable isn't all that useful : it can be sniffed off the air | ||||||||||||||
| 340 | sub make_session_id { | ||||||||||||||
| 341 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
make_session_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 342 | 0 | my $id = md5_hex($$, time, rand(9999)); | |||||||||||||
| 343 | # Format it like a UUID: B6ED3B3F-72C8-3EEF-8173-EC86AA01EA29 | ||||||||||||||
| 344 | 0 | substr( $id, 20, 0, '-' ); | |||||||||||||
| 345 | 0 | substr( $id, 16, 0, '-' ); | |||||||||||||
| 346 | 0 | substr( $id, 12, 0, '-' ); | |||||||||||||
| 347 | 0 | substr( $id, 8, 0, '-' ); | |||||||||||||
| 348 | 0 | return $id; | |||||||||||||
| 349 | } | ||||||||||||||
| 350 | |||||||||||||||
| 351 | 14 | 1; | |||||||||||||
| 352 | |||||||||||||||