… | |
… | |
918 | |
918 | |
919 | =cut |
919 | =cut |
920 | |
920 | |
921 | ############################################################################# |
921 | ############################################################################# |
922 | # object support |
922 | # object support |
|
|
923 | # |
|
|
924 | |
|
|
925 | sub _can_merge { |
|
|
926 | my ($ob1, $ob2) = @_; |
|
|
927 | |
|
|
928 | local $Storable::canonical = 1; |
|
|
929 | my $fob1 = Storable::freeze $ob1; |
|
|
930 | my $fob2 = Storable::freeze $ob2; |
|
|
931 | |
|
|
932 | $fob1 eq $fob2 |
|
|
933 | } |
923 | |
934 | |
924 | sub reattach { |
935 | sub reattach { |
925 | # basically do the same as instantiate, without calling instantiate |
936 | # basically do the same as instantiate, without calling instantiate |
926 | my ($obj) = @_; |
937 | my ($obj) = @_; |
927 | |
938 | |
… | |
… | |
2425 | |
2436 | |
2426 | utf8::encode $text; |
2437 | utf8::encode $text; |
2427 | $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); |
2438 | $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); |
2428 | } |
2439 | } |
2429 | |
2440 | |
2430 | =item $client->send_msg ($color, $type, $msg, [extra...]) |
2441 | =item $client->send_msg ($channel, $msg, $color, [extra...]) |
2431 | |
2442 | |
2432 | Send a drawinfo or msg packet to the client, formatting the msg for the |
2443 | Send a drawinfo or msg packet to the client, formatting the msg for the |
2433 | client if neccessary. C<$type> should be a string identifying the type of |
2444 | client if neccessary. C<$type> should be a string identifying the type of |
2434 | the message, with C<log> being the default. If C<$color> is negative, suppress |
2445 | the message, with C<log> being the default. If C<$color> is negative, suppress |
2435 | the message unless the client supports the msg packet. |
2446 | the message unless the client supports the msg packet. |
2436 | |
2447 | |
2437 | =cut |
2448 | =cut |
2438 | |
2449 | |
2439 | sub cf::client::send_msg { |
2450 | sub cf::client::send_msg { |
2440 | my ($self, $color, $type, $msg, @extra) = @_; |
2451 | my ($self, $channel, $msg, $color, @extra) = @_; |
2441 | |
2452 | |
2442 | $msg = $self->pl->expand_cfpod ($msg); |
2453 | $msg = $self->pl->expand_cfpod ($msg); |
2443 | |
2454 | |
2444 | return unless @extra || length $msg; |
2455 | return unless @extra || length $msg; |
2445 | |
2456 | |
|
|
2457 | $color &= ~cf::NDI_UNIQUE; # just in case... |
|
|
2458 | |
|
|
2459 | if (ref $channel) { |
|
|
2460 | # send meta info to client, if not yet sent |
|
|
2461 | unless (exists $self->{channel}{$channel->{id}}) { |
|
|
2462 | $self->{channel}{$channel->{id}} = $channel; |
|
|
2463 | $self->ext_event (channel_info => %$channel); |
|
|
2464 | } |
|
|
2465 | |
|
|
2466 | $channel = $channel->{id}; |
|
|
2467 | } |
|
|
2468 | |
2446 | if ($self->can_msg) { |
2469 | if ($self->can_msg) { |
2447 | $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $type, $msg, @extra])); |
2470 | $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $channel, $msg, @extra])); |
2448 | } else { |
2471 | } else { |
2449 | # replace some tags by gcfclient-compatible ones |
2472 | # replace some tags by gcfclient-compatible ones |
2450 | for ($msg) { |
2473 | for ($msg) { |
2451 | 1 while |
2474 | 1 while |
2452 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |
2475 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |