ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-Knuddels/Net/README
Revision: 1.2
Committed: Sun Dec 4 09:54:12 2005 UTC (18 years, 7 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 NAME
2     Net::Knuddels - www.knuddels.de protocol implementation.
3    
4     SYNOPSIS
5     use Net::Knuddels;
6    
7     DESCRIPTION
8     RTSL.
9    
10     CLASS Net::Knuddels::Protocol
11     You must call the "destroy" method of this class when you no longer use
12     it, as circular references will keep the object alive otherwise.
13    
14     new Create a new "Net::Knuddels::Protocol" object.
15    
16     $protocol->feed_data ($octets)
17     Feed raw protocol data into the decoder.
18    
19     $msg = $protocol->encode_msg (@strings)
20     Join the strings with "\0", encode the result into a protocol packet
21     and return it.
22    
23     $protocol->register ($type => $callback)
24     Register a callback for events of type $type, which is either the
25     name of a low-level event sent by the server (such as "k" for dialog
26     box) or the name of a generated event, such as "login".
27    
28     $protocol->destroy
29     *MUST* be called to destroy the object, otherwise it will leak (no
30     automatic cleanup).
31    
32     CLASS Net::Knuddels::Client
33     Implement a Knuddels client connection.
34    
35     new Net::Knuddels::Client [IO::Socket::new arguments]
36     Create a new client connection.
37    
38     Optional extra arguments:
39    
40     command_wait => $cb($client,$wait)
41     This callback will be called with the client object
42     and a time to wait. It must call the C<command_cb> method
43     after the time specified, either by a blocking wait
44     or via some event loop callback. The default implementation
45     just does a blockign wait.
46    
47     $client->fh
48     Return the fh used for communications. You are responsible for
49     calling "$client->ready" whenever the fh becomes ready for reading.
50    
51     $client->ready
52     To be called then the filehandle is ready for reading. Returns false
53     if the server closed the connection, true otherwise.
54    
55     $client->command_cb
56     Should be called by the "command_wait" callback when the timer has
57     expired, to send a delayed command to the server.
58    
59     $client->command ($type => @args)
60     Send a message of type $type and the given arguments to the server,
61     ensures a proper rate-limit.
62    
63     $client->login ($url, $unknown)
64     Send a 't' message. The default for $url is
65     "http://www.knuddels.de/applet.html?v=87&c=-3" and $unknown is 3.
66    
67     $client->enter_room ($room, $nick, $password)
68     Enters a room $room with $nick and $password. (for joining multiple
69     rooms call this multiple times)
70    
71     NOTE: i won't allow joins to multiple rooms with different
72     nick/password's, the java client reacted very confused.. don't know
73     whether the server supports this.
74    
75     $client->send_whois ($nick)
76     Sends a whois-request for $nick.
77    
78     $client->send_room_msg ($nick, $room, $message)
79     Sends a private $message to $nick over $room.
80    
81     $client->send_priv_msg ($nick, $room, $message)
82     Sends a private $message to $nick over $room.
83    
84     $client->send_join_room ($oldroom, $room)
85     Sends the server a join command for $room. This will result in a
86     room change from $oldroom to $room.
87    
88     $client->send_exit_room ($room)
89     Exits $room completly. (can be seen as counter method for
90     "enter_room ()")
91    
92     $client->register ($type => $cb)
93     See Net::Knuddels::Protocol::register. The following extra events
94     will be generated by this class:
95    
96     login
97     set_nick can only be called _after_ a login event has occured.
98    
99     msg_room => $room, $user, $msg
100     produced when a public message is uttered :)
101    
102     msg_priv => $room, $src, $dst, $msg
103     personal message from $src to $dst. better use msg_priv_nondup,
104     msg_priv_james or msg_priv_echo
105    
106     msg_priv_echo => $room, $src, $dst, $msg
107     like msg_priv, but only for echoed messages
108    
109     msg_priv_james => $room, $src, $dst, $msg
110     like msg_priv, but only for messages from James
111    
112     msg_priv_nondup => $room, $src, $dst, $msg
113     like msg_priv, but avoids duplicate messages, echos and james.
114    
115     user_list => $room, $list
116     the userlist of a channel named $room, a elmement of the list (a user)
117     looks like:
118     {
119     name => <name>,
120     flag => <some flag i don't know what it means>,
121     color => like /\d+.\d+.\d+/,
122     age => /\d+/,
123     gender => /(f|m)/,
124     picture => <the picture file to put behind the nick>
125     }
126    
127     room_info => $room, $room_info
128     some information about the $room:
129     $room_info =
130     {
131     picture => <some picturefile>
132     }
133    
134     join_room => $room, $user
135     join message of $user joined the room $room
136     $user contains the user structure (see user_list).
137    
138     part_room => $room, $user
139     part message of $user who left the room $room
140     $user contains the user structure (see user_list).
141     =cut
142    
143     sub register { my ($self, $type, $cb) = @_;
144    
145     $self->{proto}->register ($type, $cb);
146     }
147    
148     AUTHOR
149     Marc Lehmann <schmorp@schmorp.de>
150     http://home.schmorp.de/
151