Arne Gödeke > Net-PSYC-0.21 > Net::PSYC::Client

Download:
Net-PSYC-0.21.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.4   Source  

NAME ^

Net::PSYC::Client

DESCRIPTION ^

Net::PSYC::Client offers an easy-to-implement interface to build chat clients using the PSYC protocol.

SYNOPSIS ^

    use Net::PSYC::Client;

PERL API ^

psycLink( $identity )

Tries to link to (login to) the given $identity. A password, if necessary, has to be returned by main::getPassword().

psycUnlink()

Performs a log-out of the PSYC server.

register_new( $sub )

$sub is called each time a new object has to be created. Normally this occurs when the user joins a room or receives a private message. &{$sub}( uni, name[, silent]) has to return an object of a class implementing the interface specified below. The silent flag is 1 if the room does not allow talking. You may refrain from allowing input in that case and, when in a windowing environment, refrain from opening an extra window and rather direct messages to the console.

enter( $room )

Sends a request for entrance to the given room. $room may be the full UNI or just the name of the room in which case it is assumed to be on the server the user is linked to.

talk( $person, @text )

Sends a private message to the given person. $person may be a UNI or just a local nickname.

sendmsg( $target, $mc, [$data[, $vars[, $MMPvars]]] )

For a description of sendmsg() have a look at Net::PSYC. Use this sendmsg instead of the one from Net::PSYC in case you are sending messages _as_ the user you are linked to. Basically it just assigns the _identification variable for you.

register_context( $uni, $obj )

Register an object to receive all conference messages from the given UNI. Depending on whether UNI represents a person or a chatroom the object has to implement the appropriate interface:

CLIENT INTERFACE ^

In order to make it easy to implement chat-clients based on the PSYC protocol there are only a few requirements to be met by the actual user interface.

Default functions (both Person and Chatoom conference)

$obj->msg( $source, $mc, $data, $vars )

Every message that's worth printing is delivered to the msg() method. You could implement different templates for every method ($mc) though this basic implementation should be enough for simple applications.

    sub msg {
        my ($source, $mc, $data, $vars) = @_;
        print Net::PSYC::psyctext($data, $vars);
        return 1;
    }
$obj->leanforwardandchokeyourself()

When the user himself has left a room $obj->leanforwardandchokeyourself() is called to tell the object that it is no longer needed. Keep the user from sending any more messages to that room and close the window. The name of this callback method may change one day. Suggest something.

$obj->{'type'}

would be 'person' or 'place'.

Chatroom

In addition to msg every object representing a chatroom has to have the following methods

$room->members( \%members )

\%members is a reference to a hash containing nicknames and psyc addresses of all users currently in the room represented by $room. The structure of the hash is { nickname => psyc address }.

$room->enter( $nick, $uni)

enter() is called whenever someone enters $room.

$leave->leave( $nick )

leave() is called whenever someone leaves $room.

$room->topic( $topic, $nick )

Whenever the topic in this chatroom is changed this method is called with the new $topic and the $nick who changed it, if available.

SEE ALSO ^

Net::PSYC, Net::PSYC::Event, http://psyc.pages.de/, http://perlpsyc.pages.de for a bunch of scripts and a client (psycion) using Net::PSYC

AUTHORS ^

Arne Gödeke <el@goodadvice.pages.de>

COPYRIGHT ^

Copyright (c) 2004-2005 Arne Gödeke. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: