summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-02-19 17:21:34 +0100
committerYorhel <git@yorhel.nl>2012-02-19 17:21:34 +0100
commitdbefc77cec73d88bed04f10eb6a20f0e926781e2 (patch)
tree075b21d69fc9a5ee0b0e77ab188d89986a7bc9cf
parent9aa87efa574273d88e9f8e9dc870224659f608c9 (diff)
s/response/reply/g + added a link test that currently still fails
-rw-r--r--Tanja.pm8
-rwxr-xr-xtest.pl28
2 files changed, 28 insertions, 8 deletions
diff --git a/Tanja.pm b/Tanja.pm
index 670c6cd..181f513 100644
--- a/Tanja.pm
+++ b/Tanja.pm
@@ -303,11 +303,11 @@ sub _recv {
# tuple
} elsif($cmd eq 'tuple') {
$s->{serv}->send($arg[1], !$arg[0] ? undef : sub {
- $s->{hdl}->push_write('Tanja::Link::JSON' => $_[0]?'response':'close', $arg[0]+0, $_[0]?$_[0]:());
+ $s->{hdl}->push_write('Tanja::Link::JSON' => $_[0]?'reply':'close', $arg[0]+0, $_[0]?$_[0]:());
}, $s);
- # response
- } elsif($cmd eq 'response') {
+ # reply
+ } elsif($cmd eq 'reply') {
$s->{ret}{$arg[0]}->reply($arg[1]) if $s->{ret}{$arg[0]};
# close
@@ -332,7 +332,7 @@ package Tanja::Link::JSON;
use strict;
use warnings;
-my @num_to_cmd = ('', qw|register unregister tuple response close|);
+my @num_to_cmd = ('', qw|register unregister tuple reply close|);
my %cmd_to_num = map +($num_to_cmd[$_], $_), keys @num_to_cmd;
my $json;
diff --git a/test.pl b/test.pl
index 54884ba..d6487a3 100755
--- a/test.pl
+++ b/test.pl
@@ -4,6 +4,8 @@ use strict;
use warnings;
use Test::More;
use AnyEvent;
+use AnyEvent::Handle;
+use Socket;
use_ok 'Tanja';
@@ -58,10 +60,10 @@ ok !Tanja::match([2], [1]);
# Simple double-session test with return-path
-{
- my $serv = Tanja::Server->new;
- my $a = $serv->session;
- my $b = $serv->session;
+sub t_double {
+ my($sa, $sb) = @_;
+ my $a = $sa->session;
+ my $b = $sb->session;
my $done = AnyEvent->condvar;
$a->reg(["msg"], sub {
my($t, $r) = @_;
@@ -86,6 +88,24 @@ ok !Tanja::match([2], [1]);
is $n, 2;
}
+{ # same server
+ my $s = Tanja::Server->new;
+ t_double($s, $s);
+}
+
+TODO: { # different servers, linked
+ local $TODO = 'Fundamental flaw in the protocol';
+
+ my $sa = Tanja::Server->new;
+ my $sb = Tanja::Server->new;
+ socketpair my $socka, my $sockb, AF_UNIX, SOCK_STREAM, PF_UNSPEC;
+ $sa->link(0, AnyEvent::Handle->new(fh => $socka), sub { });
+ $sb->link(1, AnyEvent::Handle->new(fh => $sockb), sub { });
+ # Currently hangs
+ #t_double($sa, $sb);
+}
+
+
done_testing();