自学RTC——ServerLesson3
从其它平台迁移而来 /test.txt 打开上节的工程 添加组件RtcDataProvider3并设置Server属性为RtcHttpServer1,设置CheckOrder属性为900,使得RtcDataProvider3所处理的请求在其它请求之后(CheckOrder越小越先处理) 在当前exe所在路径下创建一个data文件夹,并在该文件夹内新建一个有内容的test.txt,然后编写一个GetFullFileName函数,用于从请求中提取文件名并转化为本地文件名 1 2 3 4 5 6 7 8 9 10 11 12 13 function GetFullFileName(fname: string): string; var DocRoot: string; begin DocRoot := ExtractFilePath(AppFileName); if Copy(DocRoot, length(DocRoot), 1) = '\' then Delete(DocRoot, length(DocRoot), 1); DocRoot := DocRoot + '\data'; fname := StringReplace(fname, '/', '\', [rfreplaceall]); Result := ExpandFileName(DocRoot + fname); if UpperCase(Copy(Result, 1, length(DocRoot))) <> UpperCase(DocRoot) then Result := ''; end; 在RtcDataProvider3的OnCheckRequest事件中写上代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 var fname: string; begin with TRtcDataServer(Sender) do begin fname := GetFullFileName(Request....