5 USES ServerLoop
,Chat
,SysUtils
,MemStream
,NetAddr
,opcode
;
10 procedure ST1(msg
:tSMsg
; data
:boolean);
11 procedure ST2(msg
:tSMsg
; data
:boolean);
12 procedure ST3(msg
:tSMsg
; data
:boolean);
14 procedure HardTimeout
;
17 procedure t
.ST1(msg
:tSMsg
; data
:boolean);
18 var r
:tMemoryStream
absolute msg
.stream
;
22 {reply from GET request}
23 write('TestFS: ST1 reply from FS: ');
24 if not data
then begin
28 op
:=msg
.stream
.ReadByte
;
29 if op
=upFAIL
then writeln('FAIL ',r
.readbyte
{,'-',r.readbyte})
30 else if op
=upINFO
then begin
32 writeln('INFO size=',r
.ReadWord(4),' final=',r
.readbyte
,' seg=',r
.readword(4));
34 end else if op
=upClose
then writeln('CLOSE')
35 else writeln('unknown');
38 procedure t
.ST2(msg
:tSMsg
; data
:boolean);
39 var r
:tMemoryStream
absolute msg
.stream
;
44 write('TestFS: ST2 reply from FS: ');
47 op
:=msg
.stream
.ReadByte
;
48 if op
=upCLOSE
then writeln('CLOSE ')
49 else if op
=upDONE
then begin
52 s
.WriteByte(opcode
.upClose
);
56 end else writeln('ack (unexpected)');
58 procedure t
.ST3(msg
:tSMsg
; data
:boolean);
61 write('TestFS: ST3 reply from FS: ');
62 if data
then writeln('unepected data') else begin
64 UnShedule(@HardTimeout
);
65 ch
.DisposeHook
:=@Rekt
;
72 writeln('TestFS: rekt');
73 FreeMem(@self
,sizeof(self
));
76 procedure t
.HardTimeout
;
78 writeln('TestFS: hardtimeout');
79 ch
.DisposeHook
:=@Rekt
;
91 assert(OptParamCount(oi
)=1,opt
+'(rcpt:tNetAddr)');
92 writeln('TestFS: rcpt '+paramstr(oi
+1));
93 new(o
); with o
^ do begin
94 ch
.Init(paramstr(oi
+1));
96 Shedule(7000,@HardTimeout
);
98 s
.WriteByte(opcode
.upFileServer
);
99 s
.WriteByte({channel}99);
100 s
.WriteByte(opcode
.upGET
);
104 s
.WriteWord($FFFFFFFF,4);