Applies to: Syncplify.me Server! Version(s): 4.x - 5.x
Please look at the properties and methods below (NOT all are listed).
For a full list of Session Objects please refer to Syncplify.me Server! manual https://serverhelp.syncplify.me/Sessionobject.html
TSrvSession = class(TPersistent) public procedure Terminate; function Minutes: double; published property User: TSrvUser; property CurURIStem: string; property CurURIQry: string; property Proto: string; property Started: TDateTime; property KBUp: double; property KBDown: double; property FilesUp: integer; property FilesDown: integer; end;
As you can see, there is a User property, which represents – at any moment in time – the User object (TSrvUser) who is currently connected and has generated that particular session.
CurURIStem and CurURIQry are only populated during certain operations, and their content is relative to the specific operation in progress. For example, during a file upload/download CurURIStem will contain the name of the file being transferred, while CurURIQry will be empty.
Proto contains the current protocol and can have either one of the following values: FTP, FTPS, FTPES, SFTPv0, SFTPv1, SFTPv2, SFTPv3, SFTPv4, SFTPv5, SFTPv6.
Started is the timestamp (in TDateTime format) of the moment the session was created (when the user has connected).
The Minutes function returns the length of the session, in minutes, at any moment in time. It is a floating-point (double precision) value, so if you need the session life-span in seconds (for example) you can simply call Session.Minutes*60.
KBUp and KBDown are pretty intuitive: they represent the amount of transferred (uploaded/downloaded) data during the specific session, in KiloBytes. Once again, this is a floating-point (double precision) value, therefore it’s easy to convert it into MB or Bytes, depending on what you need.
FilesUp and FilesDown represent respectively the total number of files uploaded and downloaded during the specific session.
Last but not least, a Terminate method, which forcefully closes the connection and terminates the session. This allows our users to write their own code to determine the validity of the current session, and terminate it in case they need to. This method can be used in conjunction with the new Blacklist(IPorNet, Type, ForHowLong).
And below is an example:
begin AddToLog('Session uploaded: '+IntToStr(Session.FilesUp)+' files for a total of '+FloatToString(Session.KBUp)+' KB'); AddToLog('Session downloaded: '+IntToStr(Session.FilesDown)+' files for a total of '+FloatToString(Session.KBDown)+' KB'); AddToLog('Session duration: '+FloatToString(Session.Minutes*60)+' seconds'); end.
Which produces the following custom output in the log file:
#Remark: 2020-06-04 17.30.07 [4N34J54FVLEBEZYB5U7V5PVXE] Session uploaded: 1 files for a total of 3.10 KB #Remark: 2020-06-04 17.30.07 [4N34J54FVLEBEZYB5U7V5PVXE] Session downloaded: 2 files for a total of 4.18 KB #Remark: 2020-06-04 17.30.07 [4N34J54FVLEBEZYB5U7V5PVXE] Session duration: 6.34 seconds