{****************************************************************************
** **
** PSSDK HNLBSession module **
** Copyright (c) 1997 - 2007 microOLAP Technologies LTD, **
** Khalturin A.P., Naumov D.A. **
** **
****************************************************************************}
unit HNLBSession;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
HNPSManager, HNPsSdkDef;
type
//---------------------------------------------------------------------------
// Class THNLBSession
//---------------------------------------------------------------------------
THNLBSession = class
private
hLbSes : Pointer;
private
function GetProcessId: DWORD;
function GetDirection: DWORD;
function GetHosts: Pointer;
function GetUserData: Pointer;
procedure SetUserData(UserData : Pointer);
protected
public
constructor Create();
destructor Destroy(); override;
public
function IsValid: BOOL;
property Handle: Pointer read hLbSes write hLbSes;
property ProcessId: DWORD read GetProcessId;
property Direction: DWORD read GetDirection;
property Hosts: Pointer read GetHosts;
property UserData: Pointer read GetUserData write SetUserData;
function Get_CreateTime(HiValue: PUINT): UINT;
function Get_CloseTime(HiValue: PUINT): UINT;
function Get_LocalDataSize(HiValue: PUINT): UINT;
function Get_RemoteDataSize(HiValue: PUINT): UINT;
published
end;
implementation
{$INCLUDE 'HNPsSdkFun.pas'}
//---------------------------------------------------------------------------
// Create - Constructor
//---------------------------------------------------------------------------
constructor THNLBSession.Create();
begin
hLbSes := nil;
end;
//---------------------------------------------------------------------------
// Destroy - Destructor
//---------------------------------------------------------------------------
destructor THNLBSession.Destroy();
begin
end;
//---------------------------------------------------------------------------
// Method - IsValid - Checks if the HNLBSession object has been created correctly.
//---------------------------------------------------------------------------
function THNLBSession.IsValid: BOOL;
begin
Result := BOOL(hLbSes <> nil);
end;
//---------------------------------------------------------------------------
// Property - ProcessId - Returns PID of the process on the local system, which is participating in TCP session.
//---------------------------------------------------------------------------
function THNLBSession.GetProcessId: DWORD;
begin
Result := LbSesGetProcessId(hLbSes);
end;
//---------------------------------------------------------------------------
// Property - Direction - Returns the direction of TCP session creation as it is defined in the HNLBDirection enumeration.
//---------------------------------------------------------------------------
function THNLBSession.GetDirection: DWORD;
begin
Result := LbSesGetDirection(hLbSes);
end;
//---------------------------------------------------------------------------
// Property - Hosts - Returns HNLBHosts object handle.
//---------------------------------------------------------------------------
function THNLBSession.GetHosts: Pointer;
begin
Result := LbSesGetHosts(hLbSes);
end;
//---------------------------------------------------------------------------
// Property - UserData - Returns user-defined value, associated with TCP session.
//---------------------------------------------------------------------------
function THNLBSession.GetUserData(): Pointer;
begin
Result := LbSesGetUserData(hLbSes);
end;
//---------------------------------------------------------------------------
// Property - UserData - Sets user-defined value, associated with TCP session.
//---------------------------------------------------------------------------
procedure THNLBSession.SetUserData(UserData : Pointer);
begin
LbSesSetUserData(hLbSes, UserData);
end;
//---------------------------------------------------------------------------
// Method - GetCreateTime - Returns the creation time of TCP session, which localhost is participating in.
//---------------------------------------------------------------------------
function THNLBSession.Get_CreateTime(HiValue: PUINT): UINT;
begin
Result := LbSesGetCreateTime(hLbSes, PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - GetCloseTime - Returns the closing time of TCP session, which localhost is participating in.
//---------------------------------------------------------------------------
function THNLBSession.Get_CloseTime(HiValue: PUINT): UINT;
begin
Result := LbSesGetCloseTime(hLbSes, PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - GetLocalDataSize - Returns the size of data, sent by localhost to the remote host in bytes.
//---------------------------------------------------------------------------
function THNLBSession.Get_LocalDataSize(HiValue: PUINT): UINT;
begin
Result := LbSesGetLocalDataSize(hLbSes, PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - GetRemoteDataSize - Returns the size of data, received by the localhost from remote host in bytes.
//---------------------------------------------------------------------------
function THNLBSession.Get_RemoteDataSize(HiValue: PUINT): UINT;
begin
Result := LbSesGetRemoteDataSize(hLbSes, PDWORD(HiValue));
end;
end.