… | |
… | |
10 | # w_s id @attr # widget member set |
10 | # w_s id @attr # widget member set |
11 | # w_g id rid @attr # widget member get |
11 | # w_g id rid @attr # widget member get |
12 | # |
12 | # |
13 | # and expects the following exti message types |
13 | # and expects the following exti message types |
14 | # w_e id @args # widget_call |
14 | # w_e id @args # widget_call |
15 | |
|
|
16 | our $DEBUG = 1; |
|
|
17 | |
15 | |
18 | cf::client->attach ( |
16 | cf::client->attach ( |
19 | on_connect => sub { |
17 | on_connect => sub { |
20 | my ($ns) = @_; |
18 | my ($ns) = @_; |
21 | |
19 | |
… | |
… | |
237 | sub msg { |
235 | sub msg { |
238 | my ($self, @msg) = @_; |
236 | my ($self, @msg) = @_; |
239 | |
237 | |
240 | if (my $ns = shift->{ns}) { |
238 | if (my $ns = shift->{ns}) { |
241 | return unless $ns->{json_coder};#d# might be gone at destroy time(??) |
239 | return unless $ns->{json_coder};#d# might be gone at destroy time(??) |
242 | warn "msg " . $ns->{json_coder}->encode (\@msg) if $DEBUG;#d# |
|
|
243 | $ns->send_packet ("ext " . $ns->{json_coder}->encode (\@msg)); |
240 | $ns->send_packet ("ext " . $ns->{json_coder}->encode (\@msg)); |
244 | } |
241 | } |
245 | } |
242 | } |
246 | |
243 | |
247 | sub alloc { |
244 | sub alloc { |
… | |
… | |
251 | |
248 | |
252 | my $proxy = bless { |
249 | my $proxy = bless { |
253 | id => $id, |
250 | id => $id, |
254 | }, "ext::widget::proxy"; |
251 | }, "ext::widget::proxy"; |
255 | |
252 | |
256 | Scalar::Util::weaken ($proxy->{ns} = $self->{ns}); |
253 | cf::weaken ($proxy->{ns} = $self->{ns}); |
257 | Scalar::Util::weaken ($self->{ns}{widget}{$id} = $proxy); |
254 | cf::weaken ($self->{ns}{widget}{$id} = $proxy); |
258 | |
255 | |
259 | $proxy |
256 | $proxy |
260 | } |
257 | } |
261 | |
258 | |
262 | sub new { |
259 | sub new { |
… | |
… | |
360 | sub msg { |
357 | sub msg { |
361 | my ($self, $type, @arg) = @_; |
358 | my ($self, $type, @arg) = @_; |
362 | |
359 | |
363 | if (my $ns = $self->{ns}) { |
360 | if (my $ns = $self->{ns}) { |
364 | my @msg = ($type, $self->{id}, @arg); |
361 | my @msg = ($type, $self->{id}, @arg); |
365 | warn "MSG " . $ns->{json_coder}->encode (\@msg) if $DEBUG;#d# |
|
|
366 | $ns->send_packet ("ext " . $ns->{json_coder}->encode (\@msg)); |
362 | $ns->send_packet ("ext " . $ns->{json_coder}->encode (\@msg)); |
367 | } |
363 | } |
368 | } |
364 | } |
369 | |
365 | |
370 | sub msg_cb { |
366 | sub msg_cb { |