Handbook
Glossary
handle-message ( peer message -- peer )
Vocabulary
bittorrent
Inputs
peer
an
object
message
an
object
Outputs
peer
an
object
Definition
IN:
bittorrent
GENERIC:
handle-message
( peer message -- peer )
Methods
USING:
accessors
bittorrent
kernel
sequences
;
M:
bitfield
handle-message
2dup
[
bitfield>>
length
]
bi@
assert=
bitfield>>
>>bitfield
;
USING:
accessors
bittorrent
kernel
;
M:
choke
handle-message
drop
t
>>peer-choking
;
USING:
accessors
bittorrent
kernel
sequences
;
M:
have-all
handle-message
drop
[
length
[
255
]
B{
}
replicate-as
]
change-bitfield
;
USING:
accessors
bittorrent
byte-arrays
kernel
sequences
;
M:
have-none
handle-message
drop
[
length
<byte-array>
]
change-bitfield
;
USING:
accessors
bittorrent
kernel
sequences
;
M:
have
handle-message
t
swap
index>>
pick
bitfield>>
set-nth
;
USING:
accessors
bittorrent
kernel
;
M:
interested
handle-message
drop
t
>>peer-interested
;
USING:
accessors
bittorrent
kernel
;
M:
not-interested
handle-message
drop
f
>>peer-interested
;
USING:
bittorrent
kernel
;
M:
object
handle-message
drop
;
USING:
accessors
bittorrent
kernel
sequences
;
M::
piece
handle-message
( peer message -- peer )
peer
current-index>>
message
index>>
assert=
peer
current-piece>>
length
message
begin>>
assert=
message
[
block>>
]
[
begin>>
]
bi
peer
current-piece>>
copy
peer
request-piece
;
USING:
accessors
bittorrent
kernel
;
M:
request
handle-message
[
index>>
]
[
begin>>
]
[
length>>
]
tri
reject-request
boa
write-message
;
USING:
accessors
bittorrent
kernel
;
M:
unchoke
handle-message
drop
f
>>peer-choking
dup
self-choking>>
[
next-block
request-piece
]
unless
;