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
;
71 procedure IgnoreData(msg
:tSMsg
);
74 //Writeln('Data: ',cnt);
79 writeln('TestFS: rekt');
80 UnShedule(@HardTimeout
);
81 FreeMem(@self
,sizeof(self
));
84 procedure t
.HardTimeout
;
86 writeln('TestFS: hardtimeout');
87 ch
.DisposeHook
:=@Rekt
;
99 assert(OptParamCount(oi
)=1,opt
+'(rcpt:tNetAddr)');
100 writeln('TestFS: rcpt '+paramstr(oi
+1));
101 new(o
); with o
^ do begin
102 ch
.Init(paramstr(oi
+1));
104 Shedule(20000,@HardTimeout
);
106 s
.WriteByte(opcode
.upFileServer
);
107 s
.WriteByte({channel}99);
108 s
.WriteByte(opcode
.upGET
);
112 s
.WriteWord($FFFFFFFF,4);
114 ServerLoop
.SetMsgHandler(4,@IgnoreData
);
115 ServerLoop
.SetMsgHandler(6,@IgnoreData
);