Original code was written in Delphi 2006.. But I think, I found the solution (untested). Somewhere Remy B. wrote that IdObjs and IdSys(??!!) has been obsolete. So the changes I made to above code were like:
- Removed IdObjs from "interface uses"
- Derived TSyncContext from TIdSeverContext (instead of TIdContext)
- And changed the constructor signature to use TIdContextThreadList
interface
uses IdContext, Classes, SysUtils, IdCustomTCPServer, StreamUtils,
IdTCPConnection, IdYarn, IdComponent; //IdObjs,
type
TRequestType = (rtNone, rtGetFileList, rtGetFile, rtGetMasterHash, rtDisconnect);
TResponseType = (rstNone, rstFile, rstString, rstStringList);
TGetMasterHash = procedure (var AHash : string) of object;
TGetFileList = procedure (var AFileList : TStrings) of object;
TGetFile = procedure (const AFilename : string; var AStream : TStream) of object;
TBytesSent = procedure (AByteCount : integer) of object;
TSyncContext = class(TIdServerContext)
private
FOnGetMasterHash: TGetMasterHash;
FOnGetFileList: TGetFileList;
FOnGetFile: TGetFile;
FOnBytesSent: TBytesSent;
FBytesSentTotal : integer;
protected
procedure WriteResponseHeader(AResponseType : TResponseType; ASize : Int64);
function ReadRequestHeader : TRequestType;
procedure DoGetMasterHash; virtual;
procedure DoGetFileList; virtual;
procedure DoGetFile(const AFilename : string); virtual;
procedure DoBytesSent(AByteCount : integer); virtual;
procedure DoWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
procedure DoWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
public
//constructor Create(AConnection: TIdTCPConnection; AYarn: TIdYarn;
//AList: TIdThreadList = nil); override;
constructor Create(AConnection: TIdTCPConnection; AYarn: TIdYarn;
AList: TIdContextThreadList = nil); override;