Server! v3.0: improved session object

Thanks to our precious beta-testers (Izzy, Antonio, and “the gang”) we have been greatly improving our session object, for the joy of all users who take advantage of Server!’s event-handling subsystem in order to run their own scripts.

In addition to all the properties and methods that were already present in v2.x, the new version will also feature the following ones:

As you can see, there is now 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. These two fields will be explained in detail in the new help file that will ship with v3.0.

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, there is a brand new 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) method that will be explained in another post.

So, thanks to these new properties, you can now use Server!’s event-handling subsystem to execute a script like the following one, for example.

Which produces the following custom output in the log file:


Print Friendly, PDF & Email
Bookmark the permalink.

Comments are closed.