| 1 | package Net::YMSG::ReceiveMessage; | ||
| 2 | use base 'Net::YMSG::Event'; | ||
| 3 | |||
| 4 | sub source | ||
| 5 | { | ||
| 6 | my $self = shift; | ||
| 7 | if (@_) { | ||
| 8 | $self->{source} = shift; | ||
| 9 | my $code = $self->_get_by_name('STATUS_CODE') || 0; | ||
| 10 | if ($code == 99) { | ||
| 11 | require Net::YMSG::NullEvent; | ||
| 12 | bless $self, 'Net::YMSG::NullEvent'; | ||
| 13 | } | ||
| 14 | } | ||
| 15 | $self->{source}; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub from | ||
| 19 | { | ||
| 20 | my $self = shift; | ||
| 21 | $self->_set_by_name('FROM', shift) if @_; | ||
| 22 | if ($self->_get_by_name('ERROR_MESSAGE')) { | ||
| 23 | return 'system'; | ||
| 24 | } | ||
| 25 | my $sender=$self->_get_by_name('FROM'); | ||
| 26 | if($sender eq 'Multiple') { | ||
| 27 | my @mult_senders = $self->_get_multiple_by_name('FROM'); | ||
| 28 | return join("\x80",@mult_senders); | ||
| 29 | } else { | ||
| 30 | return $sender; | ||
| 31 | } | ||
| 32 | |||
| 33 | } | ||
| 34 | |||
| 35 | |||
| 36 | sub body | ||
| 37 | { | ||
| 38 | my $self = shift; | ||
| 39 | $self->_set_by_name('MESSAGE', shift) if @_; | ||
| 40 | if ($self->_get_by_name('ERROR_MESSAGE')) { | ||
| 41 | return $self->_get_by_name('ERROR_MESSAGE'); | ||
| 42 | } | ||
| 43 | my $mesg=$self->_get_by_name('MESSAGE'); | ||
| 44 | if($mesg eq 'Multiple') { | ||
| 45 | my @mult_mesgs = $self->_get_multiple_by_name('MESSAGE'); | ||
| 46 | return join("\x80",@mult_mesgs); | ||
| 47 | } else | ||
| 48 | { return $mesg; | ||
| 49 | } | ||
| 50 | |||
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | sub to_string | ||
| 55 | { | ||
| 56 | my $self = shift; | ||
| 57 | sprintf "%s: %s", $self->{sender}, $self->{body}; | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; | ||
| 61 | __END__ |