line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spread::Messaging::Content; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12
|
use 5.008; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
588
|
use Spread::Messaging::Transport; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Spread::Messaging::Exception; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter Spread::Messaging::Transport); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw( |
15
|
|
|
|
|
|
|
UNRELIABLE_MESS |
16
|
|
|
|
|
|
|
RELIABLE_MESS |
17
|
|
|
|
|
|
|
FIFO_MESS |
18
|
|
|
|
|
|
|
CAUSAL_MESS |
19
|
|
|
|
|
|
|
AGREED_MESS |
20
|
|
|
|
|
|
|
SAFE_MESS |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
26
|
|
|
|
|
|
|
# Public methods |
27
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
|
|
|
|
|
|
my $class = shift; |
31
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->{message_type} = undef; |
34
|
|
|
|
|
|
|
$self->{sender} = undef; |
35
|
|
|
|
|
|
|
$self->{group} = undef; |
36
|
|
|
|
|
|
|
$self->{type} = 0; |
37
|
|
|
|
|
|
|
$self->{endian} = undef; |
38
|
|
|
|
|
|
|
$self->{message} = undef; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return($self); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub is_unreliable_mess { |
45
|
|
|
|
|
|
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return($self->message_type & UNRELIABLE_MESS); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub is_reliable_mess { |
52
|
|
|
|
|
|
|
my ($self) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return($self->message_type & RELIABLE_MESS); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub is_fifo_mess { |
59
|
|
|
|
|
|
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return($self->message_type & FIFO_MESS); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub is_causal_mess { |
66
|
|
|
|
|
|
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return($self->message_type & CAUSAL_MESS); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub is_agreed_mess { |
73
|
|
|
|
|
|
|
my ($self) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
return($self->message_type & AGREED_MESS); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub is_regular_mess { |
80
|
|
|
|
|
|
|
my ($self) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return($self->message_type & REGULAR_MESS); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub is_private_mess { |
87
|
|
|
|
|
|
|
my ($self) = @_; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
return ((index(@{$self->group}[0], '#') == 0) && |
90
|
|
|
|
|
|
|
(index(@{$self->group}[0], '#', 1))); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub is_self_discard_mess { |
95
|
|
|
|
|
|
|
my ($self) = @_; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return($self->message_type & SELF_DISCARD); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub is_reg_memb_mess { |
102
|
|
|
|
|
|
|
my ($self) = @_; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
return($self->message_type & REG_MEMB_MESS); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub is_transition_mess { |
109
|
|
|
|
|
|
|
my ($self) = @_; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return($self->message_type & TRANSITION_MESS); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub is_safe_mess { |
116
|
|
|
|
|
|
|
my ($self) = @_; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
return($self->message_type & SAFE_MESS); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub is_caused_by_join { |
123
|
|
|
|
|
|
|
my ($self) = @_; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return($self->message_type & CAUSED_BY_JOIN); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub is_caused_by_leave { |
130
|
|
|
|
|
|
|
my ($self) = @_; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return($self->message_type & CAUSED_BY_LEAVE); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub is_caused_by_disconnect { |
137
|
|
|
|
|
|
|
my ($self) = @_; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
return($self->message_type & CAUSED_BY_DISCONNECT); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub is_caused_by_network { |
144
|
|
|
|
|
|
|
my ($self) = @_; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
return($self->message_type & CAUSED_BY_NETWORK); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub is_membership_mess { |
151
|
|
|
|
|
|
|
my ($self) = @_; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
return($self->message_type & MEMBERSHIP_MESS); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub is_self_leave_mess { |
158
|
|
|
|
|
|
|
my ($self) = @_; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
return(($self->message_type & CAUSED_BY_LEAVE) && |
161
|
|
|
|
|
|
|
!($self->message_type & (REG_MEMB_MESS | TRANSITION_MESS))); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub group { |
166
|
|
|
|
|
|
|
my ($self, $p) = @_; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$self->{group} = $p if defined $p; |
169
|
|
|
|
|
|
|
return($self->{group}); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub type { |
174
|
|
|
|
|
|
|
my ($self, $p) = @_; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
$self->{type} = $p if defined $p; |
177
|
|
|
|
|
|
|
return($self->{type}); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub message { |
182
|
|
|
|
|
|
|
my ($self, $p) = @_; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
$self->{message} = $p if defined $p; |
185
|
|
|
|
|
|
|
return($self->{message}); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub message_type { |
190
|
|
|
|
|
|
|
my ($self, $p) = @_; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
$self->{message_type} = $p if defined $p; |
193
|
|
|
|
|
|
|
return($self->{message_type}); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub endian { |
198
|
|
|
|
|
|
|
my ($self, $p) = @_; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$self->{endian} = $p if defined $p; |
201
|
|
|
|
|
|
|
return($self->{endian}); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub sender { |
206
|
|
|
|
|
|
|
my ($self, $p) = @_; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
$self->{sender} = $p if defined $p; |
209
|
|
|
|
|
|
|
return($self->{sender}); |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub send { |
214
|
|
|
|
|
|
|
my ($self) = @_; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$self->SUPER::send($self->group, $self->message, $self->type); |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub recv { |
221
|
|
|
|
|
|
|
my ($self) = @_; |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
my ($message_type, $sender, $group, |
224
|
|
|
|
|
|
|
$type, $endian, $message) = $self->SUPER::recv($self); |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
$self->message_type($message_type); |
227
|
|
|
|
|
|
|
$self->sender($sender); |
228
|
|
|
|
|
|
|
$self->group($group); |
229
|
|
|
|
|
|
|
$self->type($type); |
230
|
|
|
|
|
|
|
$self->endian($endian); |
231
|
|
|
|
|
|
|
$self->message($message); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
__END__ |