Author: dylan Date: 2004-08-08 18:30:41 -0400 (Sun, 08 Aug 2004) New Revision: 341
Added: branches/protocol-v4/docs/protocol/formats.txt Removed: branches/protocol-v4/docs/formats.txt Modified: branches/protocol-v4/docs/manual/chap/commands.tex branches/protocol-v4/docs/manual/haver.tex branches/protocol-v4/main/server/lib/Haver/Server/POE/Commands.pm branches/protocol-v4/main/server/lib/Haver/Server/POE/Connection.pm Log: We now document all currently implemented protocol commands. The server might be a little funky on error messages though. Deleted: branches/protocol-v4/docs/formats.txt =================================================================== --- branches/protocol-v4/docs/formats.txt 2004-08-08 06:11:05 UTC (rev 340) +++ branches/protocol-v4/docs/formats.txt 2004-08-08 22:30:41 UTC (rev 341) @@ -1,45 +0,0 @@ -This document describes various formats -that are used in haver servers and clients. - -== Dates, Times, and Time Zones. == - -The following describes Dates, Times, Datetimes, and Time zones. - -=== Dates === - -The format for dates is YYYY-MM-DD. - -For example, Jan 12th, 2009 is 2009-01-12. - -=== Times === - -The fomat for times is HH:MM:SS (or HH:MM:SS.NN, for time intervals -less than one second). - -HH is from 00 to 23, MM is -00 to 59, and SS is 00 to 59. -For example, four thirty in the afternoon -is 16:30:00. - - -=== Time zones === - -Time zones are one of the following: - 1. + or - time GMT, i.e. -08:00 - 2. A capitalized abbreviation, i.e. CST - -=== Complete Datetimes === - -A complete datetime is as follows: - -YYYY-MM-DD HH:MM:SS [TZONE] - -The [TZONE] is optional. - - - -== File Formats == - -The standard file format for config files is YAML. - -See: http://www.yaml.org/ Modified: branches/protocol-v4/docs/manual/chap/commands.tex =================================================================== --- branches/protocol-v4/docs/manual/chap/commands.tex 2004-08-08 06:11:05 UTC (rev 340) +++ branches/protocol-v4/docs/manual/chap/commands.tex 2004-08-08 22:30:41 UTC (rev 341) @@ -7,16 +7,16 @@ \newcommand{\opts}[1]{[\param{#1\ldots}]} \newcommand{\cmd}[1]{{\bfseries #1}} \newcommand{\scmd}[1]{\cmd{#1}} +\newcommand{\error}[1]{#1} -\newcommand{\eitem}[3]{\item[#1] \param{#2} \par } +\newcommand{\eitem}[2]{\item[\error{#1}] \param{#2}} \newcommand{\citem}[1]{\item[#1] ~ \par} - \ifhas{COLOR}{ \renewcommand{\param}[1]{\textcolor{param}{\emph{#1}}} \renewcommand{\cmd}[1]{\textcolor{cmd}{{\bfseries #1}}} \renewcommand{\scmd}[1]{\textcolor{scmd}{{\bfseries #1}}} - \renewcommand{\eitem}[3]{\item[\textcolor{err}{#1}] \param{#2} \par } + \renewcommand{\error}[1]{\textcolor{err}{#1}} } @@ -97,13 +97,13 @@ \citem{\Err} None. \end{cmddef} - \begin{cmddef}{IDENT}{\param{id} \opt{mode}} + \begin{cmddef}{IDENT}{\param{id} \opt{ns}} \citem{\Desc} A client may only send this when it the server requests it with \scmd{WANT}. - Login as \param{id} in mode \param{mode}, - where \param{mode} is optional and defaults to ``user''. + Login as \param{id} in namespace \param{ns}, + where \param{ns} is optional and defaults to ``user''. \citem{\Res} \scmd{ACCEPT} will be sent if \param{id} requires @@ -112,17 +112,9 @@ \citem{\Err} \begin{errors} - \eitem{mode}{mode} - Unknown client mode ``\param{mode}''. - - \eitem{syntax}{id} - Identifier ``\param{id}'' contains illegal characters. - + \eitem{unsupported.ns}{ns} \eitem{reserved}{id} - Identifier ``\param{id}'' is reserved, you may not use it. - \eitem{used}{id} - Identifier ``\param{id}'' is being used by another client. \end{errors} \end{cmddef} @@ -141,7 +133,6 @@ \citem{\Err} \begin{errors} \eitem{badmethod}{method} - The method \param{method} is unknown. \end{errors} \end{cmddef} @@ -159,7 +150,7 @@ \citem{\Err} \begin{errors} - \eitem{nomatch}{} the password did not match. + \eitem{nomatch}{~} \end{errors} \end{cmddef} @@ -172,13 +163,12 @@ to the channel \param{where}. \citem{\Res} - \scmd{MSG} will be sent to every user in \param{cid}. + The server will send \scmd{MSG} to every user in \param{where}. \citem{\Err} \begin{errors} - \eitem{syntax.cid}{where} The channel id \param{where} contains illegal - characters or is the wrong length. - \eitem{notfound.cid}{where} The channel \param{where} does not exist. + \eitem{syntax.cid}{where} + \eitem{unknown.cid}{where} \end{errors} \end{cmddef} @@ -195,9 +185,8 @@ \citem{\Err} \begin{errors} - \eitem{syntax.uid}{to} The user id \param{to} contains illegal - characters or is the wrong length. - \eitem{notfound.uid}{to} The user \param{to} does not exist. + \eitem{syntax.uid}{to} + \eitem{unknown.uid}{to} \end{errors} \end{cmddef} @@ -216,10 +205,9 @@ \citem{\Err} \begin{errors} - \eitem{syntax.cid}{where} The channel id \param{where} contains illegal - characters or is the wrong length. - \eitem{notfound.cid}{where} The channel \param{where} does not exist. - \eitem{joined}{where} already joined to the channel. Can't join twice! + \eitem{syntax.cid}{where} + \eitem{unknown.cid}{where} + \eitem{joined}{where} \end{errors} \comment{Further errors will be added for when people are banned, etc.} \end{cmddef} @@ -238,11 +226,9 @@ \citem{\Err} \begin{errors} - \eitem{syntax.cid}{where} The channel id \param{where} contains illegal - characters or is the wrong length. - \eitem{notfound.cid}{where} The channel \param{where} does not exist. - \eitem{timetravel}{where} Many things are possible, but leaving a place you've - never been is not. + \eitem{syntax.cid}{where} + \eitem{unknown.cid}{where} + \eitem{timetravel}{where} \end{errors} \end{cmddef} @@ -260,9 +246,54 @@ \citem{\Err} None. \end{cmddef} - + \begin{cmddef}{INFO}{\param{ns} \param{id}} + \citem{\Desc} + Get information about the in the namespace \param{ns} with the id \param{id}. + This will only return the most ``relevant'' fields of the object, + not all of them. + + \citem{\Res} + The server will send \scmd{INFO}. + \citem{\Err} + \begin{errors} + \eitem{syntax.id}{ns id} + \eitem{syntax.ns}{ns} + \eitem{unknown.id}{ns id} + \eitem{unknown.ns}{ns} + \end{errors} + \end{cmddef} + + \begin{cmddef}{LINFO}{\param{where} \param{ns} \param{id}} + \citem{\Desc} + This is like INFO, except local to a channel \param{where}, + the ``L'' standing for local. The only other + difference is \param{id} may be ``*'' (the asterisk), + in which case it is as if the client sent \cmd{LINFO} + requests to every \param{ns} in \param{where}. + + \comment{Perhaps \param{ns} should be allowed to be ``*'' + as well?} + \citem{\Res} + The server will send \scmd{LINFO}. + + \citem{\Err} + \begin{errors} + \eitem{syntax.cid}{where} + \eitem{unknown.cid}{where} + \eitem{syntax.ns}{ns} + \eitem{unknown.ns}{ns} + \eitem{syntax.id}{ns id} + \eitem{unknown.id}{ns id} + \end{errors} + \end{cmddef} + + + + + + \end{commands} @@ -270,14 +301,14 @@ %> C: INFO $id %> S: INFO $type $id (list of key value pairs) %> Errors: -%> * notfound -- the id %1 of type %2 was not found. +%> * unknown -- the id %1 of type %2 was not found. %> * syntax -- the id %1 of type %2 is invalid. %> [LINFO] %> C: LINFO $cid $uid %> S: LINFO $cid $uid (key-value pairs) %> Errors: -%> * notfound.cid -- the cid %1 was not found. -%> * notfound.uid -- the uid %1 was not found. +%> * unknown.cid -- the cid %1 was not found. +%> * unknown.uid -- the uid %1 was not found. %> * syntax.cid -- the cid %1 is invalid. %> * syntax.uid -- the uid %1 is invalid. Modified: branches/protocol-v4/docs/manual/haver.tex =================================================================== --- branches/protocol-v4/docs/manual/haver.tex 2004-08-08 06:11:05 UTC (rev 340) +++ branches/protocol-v4/docs/manual/haver.tex 2004-08-08 22:30:41 UTC (rev 341) @@ -7,7 +7,7 @@ \ifhas{COLOR}{\usepackage{color}} \usepackage{url} -%\ifhas{PDF}{\usepackage[pdftex]{hyperref}} +\ifhas{PDF}{\usepackage[pdftex]{hyperref}} \input{style} Copied: branches/protocol-v4/docs/protocol/formats.txt (from rev 329, branches/protocol-v4/docs/formats.txt) Modified: branches/protocol-v4/main/server/lib/Haver/Server/POE/Commands.pm =================================================================== --- branches/protocol-v4/main/server/lib/Haver/Server/POE/Commands.pm 2004-08-08 06:11:05 UTC (rev 340) +++ branches/protocol-v4/main/server/lib/Haver/Server/POE/Commands.pm 2004-08-08 22:30:41 UTC (rev 341) @@ -79,44 +79,43 @@ } #> [IDENT] -#> C: IDENT $id [$type] +#> C: IDENT $id [$ns] #> S: ACCEPT $id #> | WANT AUTH ... #> Errors: -#> * unknown-type -- %1 is an unknown type of client. +#> * ns-unknown -- %1 is an unknown type (namespace) of client. #> * syntax -- %1 this is an illegal id. #> * reserved -- %1 is reserved for something else. #> * used -- %1 is already being used. sub cmd_IDENT { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; - my ($uid, $type) = @$args; + my ($id, $ns) = @$args; - $type ||= 'user'; + $ns ||= 'user'; return if $heap->{login}; - if ($type ne 'user') { - $kernel->yield('die', 'unknown-type', [$type]); + if ($ns ne 'user') { + $kernel->yield('die', 'ns-unknown', [$ns]); return; } - unless (Haver::Server::Object::User->is_valid_id($uid)) { - $kernel->yield('fail', 'IDENT', 'syntax', [$uid]); + unless (Haver::Server::Object::User->is_valid_id($id)) { + $kernel->yield('fail', 'IDENT', 'syntax', [$id]); $kernel->yield('want', 'IDENT'); - } elsif ($type eq 'user' and ($uid =~ /&/ or $uid =~ /@/)) { - $poe_kernel->yield('fail', 'IDENT', 'reserved', [$uid]); + } elsif ($ns eq 'user' and ($id =~ /&/ or $id =~ /@/)) { + $poe_kernel->yield('fail', 'IDENT', 'reserved', [$id]); $kernel->yield('want', 'IDENT'); } else { - if ($Registry->contains('user', $uid)) { - $poe_kernel->yield('fail', 'IDENT', 'used', [$uid]); + if ($Registry->contains('user', $id)) { + $poe_kernel->yield('fail', 'IDENT', 'used', [$id]); $kernel->yield('want', 'IDENT'); } else { my $user = new Haver::Server::Object::User( - id => $uid, + id => $id, wheel => $heap->{socket}, sid => $_[SESSION]->ID, ); $user->set( - Type => $type, Client => $heap->{client}, Rank => 0, Role => 'User', @@ -127,13 +126,13 @@ if ($@) { # This really shouldn't ever happen. my $t = localtime; - $kernel->post('Logger', 'error', "<$t> Error loading ${uid}: $@"); + $kernel->post('Logger', 'error', "<$t> Error loading ${id}: $@"); $kernel->yield('die', 'impossible', [$t]); return; } - $kernel->yield('auth', $uid, $user); + $kernel->yield('auth', $id, $user); } else { - $kernel->yield('accept', $uid, $user); + $kernel->yield('accept', $id, $user); } } @@ -181,19 +180,19 @@ #> [AUTH:PASS] #> C: AUTH:PASS $password -#> S: ACCEPT $uid +#> S: ACCEPT $id #> Errors: #> * nomatch -- password did not match, sub cmd_AUTH_PASS { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; my ($pass) = @$args; my $user = delete $heap->{want_data}{user}; - my $uid = delete $heap->{want_data}{uid}; + my $id = delete $heap->{want_data}{uid}; return if $heap->{login}; if ($pass eq $user->get('.password')) { - $kernel->yield('accept', $uid, $user); + $kernel->yield('accept', $id, $user); } else { $kernel->yield('fail', 'AUTH:PASS', 'nomatch', []); $kernel->yield('bye', 'monkeys'); @@ -215,8 +214,8 @@ #> C: MSG $cid $type @args #> S: MSG $cid $uid $type @args #> Errors: -#> * syntax.cid -- the cid %1 is invalid. -#> * notfound.cid -- the cid %1 was not found. +#> * syntax -- the cid %1 is invalid. +#> * notfound -- the cid %1 was not found. sub cmd_MSG { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; my ($cid, $type) = (shift @$args, shift @$args); @@ -233,8 +232,8 @@ #> C: PMSG $uid $type @args #> S: PMSG $uid $type @args #> Errors: -#> * syntax.uid -- the uid %1 is invalid. -#> * notfound.uid -- the uid %1 was not found. +#> * syntax -- the uid %1 is invalid. +#> * notfound -- the uid %1 was not found. sub cmd_PMSG { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; my $uid = shift @$args; @@ -249,8 +248,8 @@ #> C: JOIN $cid #> S: JOIN $cid $uid #> Errors: -#> * notfound.cid -- the cid %1 was not found. -#> * syntax.cid -- the cid %1 is invalid. +#> * notfound -- the cid %1 was not found. +#> * syntax -- the cid %1 is invalid. #> * joined -- tried to join %1 while already in it. sub cmd_JOIN { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; @@ -304,38 +303,42 @@ } #> [INFO] -#> C: INFO $id -#> S: INFO $type $id (list of key value pairs) +#> C: INFO $ns $id +#> S: INFO $ns $id (list of key value pairs) #> Errors: -#> * notfound -- the id %1 of type %2 was not found. -#> * syntax -- the id %1 of type %2 is invalid. +#> * notfound -- the id %2 of namespace %1 was not found. +#> * syntax -- the id %2 of namespace %1 is invalid. sub cmd_INFO { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; - my ($type, $id) = @$args; - my $obj = check_id($type, $id, 'INFO') or return; - my @keys = @{ $obj->get('_info') }; - my @out = ('INFO', $type, $id, map { ($_ => $obj->get($_)) } @keys); + my ($ns, $id) = @$args; + my $obj = check_id($ns, $id, 'INFO') or return; + + my @keys = eval { @{ $obj->get('_info') } }; + my @out = ('INFO', $ns, $id, map { ($_ => $obj->get($_)) } @keys); $heap->{socket}->put([EMAIL PROTECTED]); } #> [LINFO] -#> C: LINFO $cid $uid -#> S: LINFO $cid $uid (key-value pairs) +#> C: LINFO $cid $ns $id +#> S: LINFO $cid $ns $id (key-value pairs) #> Errors: +#> * notfound -- the ns/id combination %1/%2 was not found. #> * notfound.cid -- the cid %1 was not found. -#> * notfound.uid -- the uid %1 was not found. +#> * syntax -- the id %2 of namespace %1 is invalid. #> * syntax.cid -- the cid %1 is invalid. -#> * syntax.uid -- the uid %1 is invalid. sub cmd_LINFO { my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0]; - my ($cid, $uid) = @$args; - my $chan = check_cid($cid, 'LINFO') or return; + my ($cid, $ns, $id) = @$args; + my $chan = check_cid($cid, 'LINFO', 'cid') or return; + my @m = $heap->{scope}{mark} ? ('MARK', $heap->{scope}{mark}) : (); - if ($uid ne '*') { - my $user = check_uid($uid, 'LINFO') or return; + + if ($id ne '*') { + my $user = check_id($ns, $id, 'LINFO') or return; + my @keys = @{ $user->get('_info') }; - my @out = (@m, 'LINFO', $cid, $uid, map { ($_ => $user->get($_)) } @keys); + my @out = (@m, 'LINFO', $cid, $id, map { ($_ => $user->get($_)) } @keys); $heap->{socket}->put([EMAIL PROTECTED]); } else { @@ -355,30 +358,31 @@ } sub check_id { - my ($type, $id, $cmd, $d) = @_; + my ($ns, $id, $cmd, $arg, $d) = @_; + $arg ||= [$id]; unless (Haver::Server::Object->is_valid_id($id)) { - $poe_kernel->yield('fail', $cmd, err('syntax', $d), [$id]); + $poe_kernel->yield('fail', $cmd, err('syntax', $d), $arg); return undef; } - unless ($Registry->contains($type, $id)) { - $poe_kernel->yield('fail', $cmd, err('notfound', $d), [$id]); + unless ($Registry->contains($ns, $id)) { + $poe_kernel->yield('fail', $cmd, err('notfound', $d), $arg); return undef; } - return $Registry->fetch($type, $id); + return $Registry->fetch($ns, $id); } sub check_cid { - my ($id, $cmd) = @_; + my ($id, $cmd, $rest, $d) = @_; - check_id('channel', $id, $cmd, 'cid'); + check_id('channel', $id, $cmd, $rest, $d); } sub check_uid { - my ($id, $cmd) = @_; + my ($id, $cmd, $rest, $d) = @_; - check_id('user', $id, $cmd, 'uid'); + check_id('user', $id, $cmd, $rest, $d); } 1; Modified: branches/protocol-v4/main/server/lib/Haver/Server/POE/Connection.pm =================================================================== --- branches/protocol-v4/main/server/lib/Haver/Server/POE/Connection.pm 2004-08-08 06:11:05 UTC (rev 340) +++ branches/protocol-v4/main/server/lib/Haver/Server/POE/Connection.pm 2004-08-08 22:30:41 UTC (rev 341) @@ -177,7 +177,8 @@ $heap->{scope} = {}; $kernel->yield("cmd_$cmd", $args); } else { - $kernel->yield('die', 'speedy'); + $heap->{socket} = undef; + $kernel->yield('cleanup', 'SPEEDY'); } }
