--- loncom/lond 2004/07/27 11:10:47 1.214 +++ loncom/lond 2004/07/27 11:21:48 1.215 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.214 2004/07/27 11:10:47 foxr Exp $ +# $Id: lond,v 1.215 2004/07/27 11:21:48 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -56,7 +56,7 @@ my $DEBUG = 0; # Non zero to ena my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.214 $'; #' stupid emacs +my $VERSION='$Revision: 1.215 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -1035,7 +1035,8 @@ sub tie_user_hash { #--------------------- Request Handlers -------------------------------------------- # -# By convention each request handler registers itself prior to the sub declaration: +# By convention each request handler registers itself prior to the sub +# declaration: # # Handles ping requests. @@ -1062,6 +1063,33 @@ sub ping_handler { } ®ister_handler("ping", \&ping_handler, 0, 1, 1); # Ping unencoded, client or manager. +# +# Handles pong requests. Pong replies with our current host id, and +# the results of a ping sent to us via our lonc. +# +# Parameters: +# $cmd - the actual keyword that invoked us. +# $tail - the tail of the request that invoked us. +# $replyfd- File descriptor connected to the client +# Implicit Inputs: +# $currenthostid - Global variable that carries the name of the host we are +# connected to. +# Returns: +# 1 - Ok to continue processing. +# 0 - Program should exit. +# Side effects: +# Reply information is sent to the client. + +sub pong_handler { + my ($cmd, $tail, $replyfd) = @_; + + my $reply=&reply("ping",$clientname); + &Reply( $replyfd, "$currenthostid:$reply\n", "$cmd:$tail"); + return 1; +} +®ister_handler("pong", \&pong_handler, 0, 1, 1); # Pong unencoded, client or manager + + #--------------------------------------------------------------- # @@ -1174,16 +1202,10 @@ sub process_request { } -# ------------------------------------------------------------- Normal commands - if ($userinput =~ /^pong/) { # client only - if(isClient) { - my $reply=&reply("ping",$clientname); - print $client "$currenthostid:$reply\n"; - } else { - Reply($client, "refused\n", $userinput); - } +#------------------- Commands not yet in spearate handlers. -------------- + # ------------------------------------------------------------------------ ekey - } elsif ($userinput =~ /^ekey/) { # ok for both clients & mgrs + if ($userinput =~ /^ekey/) { # ok for both clients & mgrs my $buildkey=time.$$.int(rand 100000); $buildkey=~tr/1-6/A-F/; $buildkey=int(rand 100000).$buildkey.int(rand 100000);