From 11633d3fd7ce58dc31318a919704f531f4d57ece Mon Sep 17 00:00:00 2001 From: damiano Date: Tue, 18 Jan 2000 14:51:48 +0000 Subject: Add observer paramater to method bindRegexp Call observer method instead of callback function when applicable --- Ivy.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Ivy.pm b/Ivy.pm index 1b4d760..11d667f 100644 --- a/Ivy.pm +++ b/Ivy.pm @@ -42,7 +42,7 @@ use Thread::Signal; use Fcntl; use Errno; use vars qw($VERSION); -$VERSION = '4.0'; +$VERSION = '4.1'; ############################################################################# #### PROTOTYPES ##### @@ -636,9 +636,9 @@ sub start ($) ############### METHODE BIND REGEXP -sub bindRegexp ($$$) +sub bindRegexp ($$$$) { - my ($self, $regexp, $cb) = @_; + my ($self, $regexp, $cb, $observer) = @_; # on substitue les meta caracteres des regexps perl : \d, \w, \s, \e # par les classes de caracteres corespondantes de maniere a ce @@ -666,7 +666,7 @@ sub bindRegexp ($$$) last unless (defined $self->[recCbList][$id]) && @{$self->[recCbList][$id]->[1]}; } - $self->[recCbList][$id] = [$regexp, $cb]; + $self->[recCbList][$id] = [$regexp, $cb, $observer]; # on envoie les messages regexps aux processus deja connectes _sendLastRegexpToAllreadyConnected ($self, $id) ; @@ -1167,7 +1167,13 @@ sub _getMessages ($$) if (my @cb = @{$self->[recCbList][$id]->[1]}) { my $cb = shift @cb; # on split sur ETX - &$cb ($senderName, @cb, split ("\003", $valeurs)) ; + my $observer = $self->[recCbList][$id]->[2]; + if (defined $observer) { + $observer->$cb ($senderName, @cb, split ("\003", $valeurs)) ; + } + else { + &$cb ($senderName, @cb, split ("\003", $valeurs)) ; + } } else { #_sendErrorTo ($appSock, "REEGXP ID $id inconnue"); warn ("Attention Ivy::_getMessages reception d'un message " . -- cgit v1.1