… | |
… | |
188 | my $ev = $self->{cb}{$_}; |
188 | my $ev = $self->{cb}{$_}; |
189 | $_->($type, @arg) for values %$ev; |
189 | $_->($type, @arg) for values %$ev; |
190 | } |
190 | } |
191 | } |
191 | } |
192 | |
192 | |
|
|
193 | =item $msg = $protocol->encode_msg (@strings) |
|
|
194 | |
|
|
195 | Join the strings with C<\0>, encode the result into a protocol packet and |
|
|
196 | return it. |
|
|
197 | |
|
|
198 | =cut |
|
|
199 | |
|
|
200 | sub encode_msg($@) { |
|
|
201 | my ($self, @args) = @_; |
|
|
202 | my $msg = Net::Knuddels::encode join "\0", @args; |
|
|
203 | } |
|
|
204 | |
193 | =item $protocol->register ($type => $callback) |
205 | =item $protocol->register ($type => $callback) |
194 | |
206 | |
195 | Register a callback for events of type C<$type>, which is either the name |
207 | Register a callback for events of type C<$type>, which is either the name |
196 | of a low-level event sent by the server (such as "k" for dialog box) or |
208 | of a low-level event sent by the server (such as "k" for dialog box) or |
197 | the name of a generated event, such as C<login_info>. |
209 | the name of a generated event, such as C<login_info>. |