Author: dylan
Date: 2005-01-08 02:10:29 -0500 (Sat, 08 Jan 2005)
New Revision: 548
Added:
trunk/main/server/lib/Haver/Server/Entity/Avatar.pm
trunk/main/server/lib/Haver/Server/Entity/Room.pm
trunk/main/server/lib/Haver/Server/Speaker.pm
Removed:
trunk/main/server/lib/Haver/Server/Avatar.pm
trunk/main/server/lib/Haver/Server/Entity/Channel.pm
trunk/main/server/lib/Haver/Server/Entity/User.pm
Modified:
trunk/main/server/lib/Haver/Server/Entity.pm
Log:
various name changes.
Deleted: trunk/main/server/lib/Haver/Server/Avatar.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Avatar.pm 2005-01-08 07:06:14 UTC
(rev 547)
+++ trunk/main/server/lib/Haver/Server/Avatar.pm 2005-01-08 07:10:29 UTC
(rev 548)
@@ -1,225 +0,0 @@
-# Haver::Server::Avatar,
-# this creates a session, which represents the user...
-#
-# Copyright (C) 2003 Dylan William Hardison.
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-# TODO, write POD. Soon.
-package Haver::Server::Avatar;
-use strict;
-use Carp qw(croak confess carp cluck);
-
-use POE qw(
- Wheel::ReadWrite
- Driver::SysRW
- Preprocessor
- Filter::Haver
-);
-
-use Haver::Server::Commands;
-use Haver::Server::Registry qw( $Registry );
-
-our $RELOAD = 1;
-
-sub create {
- my ($class) = shift;
- # ASSERT: (@_ == 1 and ref($_[0]) eq 'HASH') or ((@_ % 2) == 0);
- my $opts = @_ == 1 ? $_[0] : { @_ };
-
-
- POE::Session->create(
- package_states => [
- $class => {
- # POE states
- _start => '_start',
- _stop => '_stop',
- _default => '_default',
-
-
- # Wheel states
- input => 'on_input',
- error => 'on_error',
- flush => 'on_flush',
-
- # Utility states
- cleanup => 'on_cleanup',
- 'shutdown' => 'on_shutdown',
- 'fail' => 'on_fail',
- 'oops' => 'on_oops',
- },
- ],
- heap => {},
- args => [ $opts ],
- );
-}
-
-sub _start {
- my ($heap, $session, $kernel, $opt) = @_[ HEAP, SESSION, KERNEL,
ARG0];
- my ($address, $socket, $port) = ($opt->{address}, delete $opt->{sock},
$opt->{port});
-
- $kernel->post('Logger', 'note', "Connection from ${address}:$port");
-
-
- ## breaks ssl.
- #binmode $socket, ":utf8";
- my $client = new POE::Wheel::ReadWrite(
- Handle => $socket,
- Driver => new POE::Driver::SysRW,
- Filter => new POE::Filter::Haver,
- InputEvent => 'input',
- FlushedEvent => 'flush',
- ErrorEvent => 'error',
- );
-
- %$heap = (
- %$opt,
- client => $client,
- shutdown => 0,
- plonk => 0,
- plugin => new Haver::Server::Plugin::Loader,
- );
-
- $heap->{plugin}->load('Haver::Server::Commands::Connection');
- $kernel->call($session, 'init');
-}
-
-
-sub _stop {
- my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
-
- my ($address, $port) = @$heap{qw(address port)};
- $kernel->call('Logger', 'note', "Lost connection from
${address}:$port");
-}
-
-
-sub on_ready {
- my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
-
- $heap->{plugin}->unload('Haver::Server::Commands::Connection');
- $heap->{plugin}->load('Haver::Server::Commands::Channel');
-}
-
-sub _default {
- my ($kernel, $heap, $event, $args) = @_[KERNEL, HEAP, ARG0, ARG1];
-
- my $cmd = $event;
- if ($event =~ s/^evt_//) {
- $kernel->call($_[SESSION], 'unknown_cmd', $event, $_[ARG1][0],
$cmd);
- }
- $kernel->post('Logger', 'error', "Unknown event: $event");
-
- return 0;
-}
-
-sub on_input {
- my ($kernel, $heap, $args) = @_[KERNEL, HEAP, ARG0];
-
- my @copy = @$args;
- foreach (@copy) {
- next unless defined;
- #my @foo = split(//, $_);
- #foreach my $c (@foo) {
- #$c = ord($c);
- #$c = "[$c]";
- #}
- #$_ = join('', @foo);
- s/\e/<ESC>/g;
- s/\r/<CR>/g;
- s/\n/<LF>/g;
- s/\t/<TAB>/g;
- p
- }
- my $raw = join("\t", map { defined $_ ? $_ : '' } @copy);
- $kernel->post('Logger', 'raw', $raw);
-
- return if $heap->{plonk};
- return if $heap->{shutdown};
-
- my $want = 0;
- my $cmd = shift @$args;
- my $event = 'evt_' . $cmd;
-
- $kernel->yield($event, $args, $cmd);
-
-}
-
-sub on_flush {
- my ($kernel, $heap) = @_[KERNEL, HEAP];
-
- if ($heap->{shutdown}) {
- delete $heap->{client};
- }
-}
-
-
-sub on_error {
- my ($kernel, $heap, $operation, $errnum, $errstr) = @_[KERNEL, HEAP,
ARG0..ARG3];
-
- $kernel->post('Logger', 'error',
- "Socket generated $operation error ${errnum}: $errstr");
-
-
- $kernel->yield('shutdown', 'DISCON');
-}
-
-
-sub on_shutdown {
- my ($kernel, $heap, $session, @args) = @_[KERNEL, HEAP, SESSION, ARG0
.. $#_];
- return if $heap->{shutdown};
-
- $kernel->call('Logger', 'note', 'Shutting down client session.');
- eval { $heap->{client}->put(['BYE', @args]) };
- $heap->{shutdown} = 1;
- $kernel->alarm_remove_all();
-
- $kernel->yield('cleanup', @args);
-}
-
-sub on_cleanup {
- my ($kernel, $heap, @args) = @_[KERNEL, HEAP, ARG0 .. $#_];
-
-}
-
-sub on_oops {
- my ($kernel, $heap, $err, $data) = @_[KERNEL, HEAP, ARG0 .. $#_];
-
- if (not defined $data) {
- $data = [];
- }
-
- if (not ref $data) {
- $data = [$data];
- }
-
- eval { $heap->{client}->put(['OOPS', $err, @$data]) };
- $kernel->yield('shutdown', 'OOPS');
-}
-sub on_fail {
- my ($kernel, $heap, $cmd, $err, $data) = @_[KERNEL, HEAP, ARG0 .. $#_];
-
- if (not defined $data) {
- $data = [];
- }
-
- if (not ref $data) {
- $data = [$data];
- }
-
- $kernel->post('Logger', 'fail', "failing $heap->{uid} with $cmd -
$err");
- eval { $heap->{client}->put(['FAIL', $cmd, $err, @$data]) };
-}
-
-1;
Copied: trunk/main/server/lib/Haver/Server/Entity/Avatar.pm (from rev 547,
trunk/main/server/lib/Haver/Server/Entity/User.pm)
Deleted: trunk/main/server/lib/Haver/Server/Entity/Channel.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Channel.pm 2005-01-08
07:06:14 UTC (rev 547)
+++ trunk/main/server/lib/Haver/Server/Entity/Channel.pm 2005-01-08
07:10:29 UTC (rev 548)
@@ -1,171 +0,0 @@
-# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
-# This module is copyrighted, see end of file for details.
-package Haver::Server::Object::Channel;
-use strict;
-use warnings;
-use Haver::Server::Object;
-use base qw( Haver::Server::Object );
-
-our $VERSION = 0.10;
-
-sub initialize {
- my ($me) = @_;
-
- $me->SUPER::initialize;
- $me->{_contents} = {};
-}
-
-sub namespace {
- return 'channel';
-}
-
-sub add {
- my ($me, $object) = @_;
-
- my $ns = $object->namespace;
- my $id = $object->id;
-
- croak ref($me) . " can't contain $object!" unless
$me->can_contain($object);
-
- $me->{_contents}{$ns}{$id} = $object;
-}
-
-sub can_contain {
- my ($me, $object) = @_;
-
- $object->namespace eq 'user';
-}
-
-sub fetch {
- my ($me, $ns, $id) = @_;
-
- return undef unless exists $me->{_contents}{$ns};
- return undef unless exists $me->{_contents}{$ns}{$id};
- return $me->{_contents}{$ns}{$id};
-}
-
-sub remove {
- my ($me, $ns, $id) = @_;
-
- return undef unless exists $me->{_contents}{$ns};
- return undef unless exists $me->{_contents}{$ns}{$id};
- return delete $me->{_contents}{$ns}{$id};
-}
-
-sub contents {
- my ($me, $ns) = @_;
- my @values = ();
-
- if (exists $me->{_contents}{$ns}) {
- @values = values %{ $me->{_contents}{$ns} };
- }
-
- return wantarray ? @values : [EMAIL PROTECTED];
-}
-
-sub contains {
- my ($me, $ns, $id) = @_;
-
- return undef unless exists $me->{_contents}{$ns};
- return exists $me->{_contents}{$ns}{$id};
-}
-
-
-
-
-1;
-
-# Now for the API manual.
-__END__
-
-=head1 NAME
-
-Haver::Server::Object::Channel - A Server::Object that contains
Server::Objects.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Object::Channel;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=head1 INHERITENCE
-
-Haver::Server::Object::Channel extends L<Haver::Server::Object>.
-
-=head1 METHODS
-
-Haver::Server::Object::Channel implements the following methods:
-
-=head2 namespace(Z<>)
-
-Returns 'channel'.
-
-=head2 add($thing)
-
-This inserts the object $thing to the contents of the channel,
-provided that $thing supports both the namespace() and id() methods,
-and C<<$channel->can_contain($thing)>> returns a true value.
-
-For Haver::Server::Object::Channel, can_contain will return true
-if C<<$thing->namespace() eq 'user'>>. This can be changed in subclasses.
-
-=head2 can_contain($thing)
-
-Returns true of C<<$thing->namespace()>> is equal to 'user'.
-
-=head2 fetch($ns, $id)
-
-Returns the object with namespace $ns and id $id if such an object exists,
-undef otherwise.
-
-=head2 remove($ns, $id)
-
-Deletes and returns the object with namesapce $ns and id $id if it exists,
-returns undef otherwise.
-
-=head2 contains($ns, $id)
-
-Returns true if an object with namespace $ns and id $id exists, false
otherwise.
-
-=head2 contents($ns)
-
-Returns all objects under namespace $ns.
-Will return empty list if there are no object under the namespace.
-
-In scalar context, returns an arrayref. In list context, it returns a list.
-
-=head1 BUGS
-
-None known. Bug reports are welcome. Please use our bug tracker at
-L<http://gna.org/bugs/?func=additem&group=haver>.
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 SEE ALSO
-
-L<Haver::Server::Object::User>, L<Haver::Server::Object::User>.
-
-=head1 COPYRIGHT and LICENSE
-
-Copyright (C) 2004, 2005 by Dylan Hardison
-
-This module is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This module is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Copied: trunk/main/server/lib/Haver/Server/Entity/Room.pm (from rev 547,
trunk/main/server/lib/Haver/Server/Entity/Channel.pm)
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Channel.pm 2005-01-08
07:06:14 UTC (rev 547)
+++ trunk/main/server/lib/Haver/Server/Entity/Room.pm 2005-01-08 07:10:29 UTC
(rev 548)
@@ -0,0 +1,171 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Entity::Room;
+use strict;
+use warnings;
+use Haver::Server::Object;
+use base qw( Haver::Server::Object );
+
+our $VERSION = 0.10;
+
+sub initialize {
+ my ($me) = @_;
+
+ $me->SUPER::initialize;
+ $me->{_contents} = {};
+}
+
+sub namespace {
+ return 'channel';
+}
+
+sub add {
+ my ($me, $object) = @_;
+
+ my $ns = $object->namespace;
+ my $id = $object->id;
+
+ croak ref($me) . " can't contain $object!" unless
$me->can_contain($object);
+
+ $me->{_contents}{$ns}{$id} = $object;
+}
+
+sub can_contain {
+ my ($me, $object) = @_;
+
+ $object->namespace eq 'user';
+}
+
+sub fetch {
+ my ($me, $ns, $id) = @_;
+
+ return undef unless exists $me->{_contents}{$ns};
+ return undef unless exists $me->{_contents}{$ns}{$id};
+ return $me->{_contents}{$ns}{$id};
+}
+
+sub remove {
+ my ($me, $ns, $id) = @_;
+
+ return undef unless exists $me->{_contents}{$ns};
+ return undef unless exists $me->{_contents}{$ns}{$id};
+ return delete $me->{_contents}{$ns}{$id};
+}
+
+sub contents {
+ my ($me, $ns) = @_;
+ my @values = ();
+
+ if (exists $me->{_contents}{$ns}) {
+ @values = values %{ $me->{_contents}{$ns} };
+ }
+
+ return wantarray ? @values : [EMAIL PROTECTED];
+}
+
+sub contains {
+ my ($me, $ns, $id) = @_;
+
+ return undef unless exists $me->{_contents}{$ns};
+ return exists $me->{_contents}{$ns}{$id};
+}
+
+
+
+
+1;
+
+# Now for the API manual.
+__END__
+
+=head1 NAME
+
+Haver::Server::Entity::Room - A Server::Object that contains Server::Objects.
+
+=head1 SYNOPSIS
+
+ use Haver::Server::Entity::Room;
+ # FIXME
+
+=head1 DESCRIPTION
+
+FIXME
+
+=head1 INHERITENCE
+
+Haver::Server::Entity::Room extends L<Haver::Server::Object>.
+
+=head1 METHODS
+
+Haver::Server::Entity::Room implements the following methods:
+
+=head2 namespace(Z<>)
+
+Returns 'channel'.
+
+=head2 add($thing)
+
+This inserts the object $thing to the contents of the channel,
+provided that $thing supports both the namespace() and id() methods,
+and C<<$channel->can_contain($thing)>> returns a true value.
+
+For Haver::Server::Entity::Room, can_contain will return true
+if C<<$thing->namespace() eq 'user'>>. This can be changed in subclasses.
+
+=head2 can_contain($thing)
+
+Returns true of C<<$thing->namespace()>> is equal to 'user'.
+
+=head2 fetch($ns, $id)
+
+Returns the object with namespace $ns and id $id if such an object exists,
+undef otherwise.
+
+=head2 remove($ns, $id)
+
+Deletes and returns the object with namesapce $ns and id $id if it exists,
+returns undef otherwise.
+
+=head2 contains($ns, $id)
+
+Returns true if an object with namespace $ns and id $id exists, false
otherwise.
+
+=head2 contents($ns)
+
+Returns all objects under namespace $ns.
+Will return empty list if there are no object under the namespace.
+
+In scalar context, returns an arrayref. In list context, it returns a list.
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<Haver::Server::Object::User>, L<Haver::Server::Object::User>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2004, 2005 by Dylan Hardison
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+=cut
Deleted: trunk/main/server/lib/Haver/Server/Entity/User.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/User.pm 2005-01-08 07:06:14 UTC
(rev 547)
+++ trunk/main/server/lib/Haver/Server/Entity/User.pm 2005-01-08 07:10:29 UTC
(rev 548)
@@ -1,132 +0,0 @@
-# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
-# This module is copyrighted, see end of file for details.
-package Haver::Server::Object::User;
-use strict;
-use warnings;
-use Carp;
-
-use Haver::Preprocessor;
-use Haver::Server::Object;
-use base qw( Haver::Server::Object );
-use Scalar::Util;
-
-our $VERSION = 0.05;
-
-
-sub initialize {
- my ($me) = @_;
- # ASSERT: exists $me->{wheel};
-
- $me->{_access} = {};
- $me->{_channels} = {};
-}
-
-sub wheel { $_[0]{wheel} }
-
-
-sub add_channel {
- my ($me, $cid) = @_;
- # ASSERT: defined $cid;
- croak "add_channel(): channel previously added!" if exists
$me->{_channels}{$cid};
- $me->{_channels}{$cid} = 1;
-}
-
-sub remove_channel {
- my ($me, $cid) = @_;
- # ASSERT: defined $cid;
- croak "remove_channel(): channel not added!" if not exists
$me->{_channels}{$cid};
-
- delete $me->{_channels}{$cid};
-}
-
-sub has_channel {
- my ($me, $cid) = @_;
- # ASSERT: defined $cid;
-
- exists $me->{_channels}{$cid};
-}
-
-sub channels {
- my ($me) = @_;
- my @chans = keys %{ $me->{_channels} };
-
- wantarray ? @chans : [EMAIL PROTECTED] ;
-}
-
-# Now for the API manual.
-__END__
-
-=head1 NAME
-
-Haver::Server::Object::User - An object that contains information about a user.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Object::User;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=head1 INHERITENCE
-
-Haver::Server::Object::Object extends L<Haver::Server::Object>.
-
-=head1 METHODS
-
-Haver::Server::Object::Object implements the following methods:
-
-=head2 namespace(Z<>)
-
-Returns 'user';
-
-=head2 add_channel($cid)
-
-Add the channel id $cid to the list of channels the user is joined to.
-
-=head2 remove_channel($cid)
-
-Remove the channel id $cid from the list of joined channels.
-
-=head2 has_channel($cid)
-
-Returns true if the user is joined to the channel $cid. False otherwise.
-
-=head2 channels()
-
-In scalar context, returns an arrayref of the channels this user is joined to.
-In list context, returns a list.
-
-=head1 BUGS
-
-None known. Bug reports are welcome. Please use our bug tracker at
-L<http://gna.org/bugs/?func=additem&group=haver>.
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 SEE ALSO
-
-L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
-
-=head1 COPYRIGHT and LICENSE
-
-Copyright (C) 2004, 2005 by Dylan Hardison
-
-This module is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This module is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Modified: trunk/main/server/lib/Haver/Server/Entity.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity.pm 2005-01-08 07:06:14 UTC
(rev 547)
+++ trunk/main/server/lib/Haver/Server/Entity.pm 2005-01-08 07:10:29 UTC
(rev 548)
@@ -1,6 +1,6 @@
# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
# This module is copyrighted, see end of file for details.
-package Haver::Server::Object;
+package Haver::Server::Entity;
use strict;
use warnings;
use Haver::Preprocessor;
@@ -85,11 +85,11 @@
__END__
=head1 NAME
-Haver::Server::Object - Base class for Users and Channels.
+Haver::Server::Entity - Base class for Users and Channels.
=head1 SYNOPSIS
- use Haver::Server::Object;
+ use Haver::Server::Entity;
# FIXME
=head1 DESCRIPTION
@@ -98,11 +98,11 @@
=head1 INHERITENCE
-Haver::Server::Object extends L<Haver::Base>.
+Haver::Server::Entity extends L<Haver::Base>.
=head1 METHODS
-Haver::Server::Object supports the following methods:
+Haver::Server::Entity supports the following methods:
=head2 new(%params | \%params)
@@ -146,7 +146,7 @@
=head1 SEE ALSO
-L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
+L<Haver::Server::Entity::Avatar>, L<Haver::Server::Entity::Room>.
=head1 COPYRIGHT and LICENSE
Copied: trunk/main/server/lib/Haver/Server/Speaker.pm (from rev 546,
trunk/main/server/lib/Haver/Server/Avatar.pm)