2 {Upload Manager for brodnetd}
4 multiplex uploads thru TC connection
8 - handle retransmit requests
10 - deprioritize/cancel uploads
11 keep one TC connection per peer (+expire-delete)
12 => need 'chat' protocol
16 - send file request (chat)
17 (GET channel CHK hash ofset length)
18 - channel, client choose, reuse
19 - prepare recv channel
20 - wait reply (positive/negative)
26 type tUH
= procedure(var tcs
:tTCS
): of object;
27 procedure AddUpload(rcpt
:tNetAddr
; channel
:byte; handler
:tUH
);
28 {delete with handler=nil}
32 type tPeer_ptr
=^tPeer
; tPeer
=object
34 prv
: ^tUH
; {dynamic array}
35 prvc
: word; {number of allocated items unused are nil}
38 function AllocChannel
:word;
42 function FindPeer(const addr
:tNetAddr
): tPeer_ptr
;
45 while assigned(result
) do begin
46 if result
^.tcs
.remote
=addr
then exit
;
51 procedure AddUpload(rcpt
:tNetAddr
; channel
:byte; handler
:tUH
);
55 if not assigned(peer
) then begin
58 peer
^.prvc
:=channel
+1;
59 peer
^.prv
:=GetMem(sizeof(peer
^.prv
)*peer
^.prvc
);
62 peer
^.tcs
.CanSend
:=@OnCont
;
66 if peer
^.tcs
.txLastSize
=0 then peer
^.tcs
.Start
;