5 USES ServerLoop
,Chat
,SysUtils
,MemStream
,NetAddr
,opcode
,Download
;
11 procedure ST1(msg
:tSMsg
; data
:boolean);
12 procedure ST2(msg
:tSMsg
; data
:boolean);
13 procedure ST3(msg
:tSMsg
; data
:boolean);
15 procedure HardTimeout
;
18 procedure t
.ST1(msg
:tSMsg
; data
:boolean);
19 var r
:tMemoryStream
absolute msg
.stream
;
23 {reply from GET request}
24 write('TestFS: ST1 reply from FS: ');
25 if not data
then begin
29 op
:=msg
.stream
.ReadByte
;
30 if op
=upFAIL
then writeln('FAIL ',r
.readbyte
{,'-',r.readbyte})
31 else if op
=upINFO
then begin
33 writeln('INFO size=',r
.ReadWord(4),' final=',r
.readbyte
,' seg=',r
.readword(4));
35 UnShedule(@HardTimeout
);
37 end else if op
=upClose
then writeln('CLOSE')
38 else writeln('unknown');
41 procedure t
.ST2(msg
:tSMsg
; data
:boolean);
42 var r
:tMemoryStream
absolute msg
.stream
;
47 write('TestFS: ST2 reply from FS: ');
50 op
:=msg
.stream
.ReadByte
;
51 if op
=upCLOSE
then writeln('CLOSE ')
52 else if op
=upDONE
then begin
55 s
.WriteByte(opcode
.upClose
);
59 end else writeln('ack (unexpected)');
61 procedure t
.ST3(msg
:tSMsg
; data
:boolean);
64 write('TestFS: ST3 reply from FS: ');
65 if data
then writeln('unepected data') else begin
67 ch
.DisposeHook
:=@Rekt
;
74 procedure IgnoreData(msg
:tSMsg
);
77 //Writeln('Data: ',cnt);
82 writeln('TestFS: rekt');
83 UnShedule(@HardTimeout
);
84 FreeMem(@self
,sizeof(self
));
87 procedure t
.HardTimeout
;
89 writeln('TestFS: hardtimeout');
90 ch
.DisposeHook
:=@Rekt
;
102 assert(OptParamCount(oi
)=1,opt
+'(rcpt:tNetAddr)');
103 writeln('TestFS: rcpt '+paramstr(oi
+1));
104 new(o
); with o
^ do begin
105 ch
.Init(paramstr(oi
+1));
108 Shedule(20000,@HardTimeout
);
110 s
.WriteByte(opcode
.upFileServer
);
111 s
.WriteByte({channel}99);
112 s
.WriteByte(opcode
.upGET
);
116 s
.WriteWord($FFFFFFFF,4);
118 //ServerLoop.SetMsgHandler(4,@IgnoreData);
119 //ServerLoop.SetMsgHandler(6,@IgnoreData);