TROAsyncSuperChannelWorker

Overview

TROAsyncSuperChannelWorker is a base class that contains methods for sending/receiving data from and to clients.

TROAsyncSuperChannelWorker is used internally in the TROBaseAsyncSuperTcpServer.

Location

Implements

 

constructor Create

Creates a new instance.

constructor Create(aConnection: IROAbstractTCPConnection)

Parameters:

  • aConnection:

ClientID

Uniquely identifies the client on the server. This allows the server to track the session state between client requests.

property ClientID: TGuid read write

Connected  protected virtual

This procedure is called when the client connects to the server.

procedure Connected

Connection

Specifies the IROAbstractTCPConnection that was used in the constructor.

property Connection: IROAbstractTCPConnection read write

Disconnect

Called to disconnect the current connection.

procedure Disconnect

Disconnected  protected virtual

Called after the connection to the remote party is disconnected to do any specific actions at this moment.

procedure Disconnected(var RestartLoop: Boolean)

Parameters:

  • RestartLoop: If set to true indicates that the connection is going to be reestablished.

DoSetup

Performs the initial initialization.

procedure DoSetup

GenerateId

Generates a package ID.

function GenerateId: Integer

GetDefaultResponse  protected virtual

Returns a string that is transmitted to the socket in case of any superchannel protocol error. Superchannel protocol errors can happen when the remote party behavior differs from the one expected according to the superchannel protocol. Usually this happens when non-super channel is used on the remote side or remote superchannel implementation has errors.

function GetDefaultResponse: string

GetTransportObject  protected

Returns itself.

function GetTransportObject: TObject

HaveGuid  protected virtual

This procedure calls the Connected method.

procedure HaveGuid

IncomingData  protected virtual abstract

Allows to perform additional actions when a package is received.

procedure IncomingData(Id: Integer; aData: TBytes)

Parameters:

  • Id: The package id received.
  • aData: The stream containing the incoming data, payload only.

IsConnected

Specifies the current state.

property IsConnected: Boolean read write

IsServer  protected

Specifies on which side (client or server) the TROAsyncSuperChannelWorker is used.

property IsServer: Boolean read write

LastData  protected

Specifies the timestamp of the last operation.

property LastData: TDateTime read write

MaxPackageSize

Sets the maximum size for data packages that the channel will transport (default is 10485760, 10 MB).

property MaxPackageSize: Integer read write

NewInstance  override    (declared in TROInterfacedObject)

Creates and returns a new instance of the interfaced object, initializing its reference counter with 1.

class function NewInstance: TObject

PingFrequency  protected

Determines the time interval in seconds between attempts to send a ping package (such packages are used to make sure the remote party is up ad running, has nothing to with ICMP pings).

property PingFrequency: Integer read write

PingTimeout  protected

Determines the time interval in seconds for remote party to answer a ping request package (such packages are used to make sure the remote party is up and running, has nothing to with ICMP pings). If ping request was not answered than the connection is considered broken so the client side reconnects and the server side removes the lost connection data from the memory.

property PingTimeout: Integer read write

ProcessOption  protected

Processes options that are received from the other sid

procedure ProcessOption(Data: TBytes)

Parameters:

  • Data:

RefCount    (declared in TROInterfacedObject)

Provides read-only access to the reference counter. When this value reaches zero, the object is freed.

property RefCount: Integer read write

SendError

Sends errorcode to the other side.

procedure SendError(Id: Integer; Error: Byte)

Parameters:

  • Id: The package id to use when sending data.
  • Error: The error code.

SendOptions  protected

Sends options to the other side.

procedure SendOptions(aData: string)

Parameters:

  • aData: The package content, in the string form.

SendPackage

Sends a package to the other side.

function SendPackage(aData: TStream; Id: Integer): IROPackageAck_Async

Parameters:

  • aData: The data to send, payload only.
  • Id: The package id to use, 0 may be passed to generate and use a new id.

SetAckDetails  protected virtual

procedure SetAckDetails(Id: Integer; Oke: Boolean; ErrorNo: Integer)

Parameters:

  • Id:
  • Oke:
  • ErrorNo:

SkipAck

Defines whether "acknowledgement" messages are skipped.

property SkipAck: Boolean read write

SupportsOptions  protected

Checks for SkipAck and sends options to the other side.

procedure SupportsOptions

WaitForAck

The utility method to wait for acknowledgement package from the remote party and analyzes it's content.

class procedure WaitForAck(pkg: IROPackageAck_Async; Timeout: Integer)

Parameters:

  • pkg: The object describing acknowledgement package.
  • Timeout: Package wait timeout.

 

ClientID

Uniquely identifies the client on the server. This allows the server to track the session state between client requests.

property ClientID: TGuid read write

Connection

Specifies the IROAbstractTCPConnection that was used in the constructor.

property Connection: IROAbstractTCPConnection read write

IsConnected

Specifies the current state.

property IsConnected: Boolean read write

IsServer  protected

Specifies on which side (client or server) the TROAsyncSuperChannelWorker is used.

property IsServer: Boolean read write

LastData  protected

Specifies the timestamp of the last operation.

property LastData: TDateTime read write

MaxPackageSize

Sets the maximum size for data packages that the channel will transport (default is 10485760, 10 MB).

property MaxPackageSize: Integer read write

PingFrequency  protected

Determines the time interval in seconds between attempts to send a ping package (such packages are used to make sure the remote party is up ad running, has nothing to with ICMP pings).

property PingFrequency: Integer read write

PingTimeout  protected

Determines the time interval in seconds for remote party to answer a ping request package (such packages are used to make sure the remote party is up and running, has nothing to with ICMP pings). If ping request was not answered than the connection is considered broken so the client side reconnects and the server side removes the lost connection data from the memory.

property PingTimeout: Integer read write

RefCount    (declared in TROInterfacedObject)

Provides read-only access to the reference counter. When this value reaches zero, the object is freed.

property RefCount: Integer read write

SkipAck

Defines whether "acknowledgement" messages are skipped.

property SkipAck: Boolean read write

 

NewInstance  override    (declared in TROInterfacedObject)

Creates and returns a new instance of the interfaced object, initializing its reference counter with 1.

class function NewInstance: TObject

WaitForAck

The utility method to wait for acknowledgement package from the remote party and analyzes it's content.

class procedure WaitForAck(pkg: IROPackageAck_Async; Timeout: Integer)

Parameters:

  • pkg: The object describing acknowledgement package.
  • Timeout: Package wait timeout.

 

constructor Create

Creates a new instance.

constructor Create(aConnection: IROAbstractTCPConnection)

Parameters:

  • aConnection:

Connected  protected virtual

This procedure is called when the client connects to the server.

procedure Connected

Disconnect

Called to disconnect the current connection.

procedure Disconnect

Disconnected  protected virtual

Called after the connection to the remote party is disconnected to do any specific actions at this moment.

procedure Disconnected(var RestartLoop: Boolean)

Parameters:

  • RestartLoop: If set to true indicates that the connection is going to be reestablished.

DoSetup

Performs the initial initialization.

procedure DoSetup

GenerateId

Generates a package ID.

function GenerateId: Integer

GetDefaultResponse  protected virtual

Returns a string that is transmitted to the socket in case of any superchannel protocol error. Superchannel protocol errors can happen when the remote party behavior differs from the one expected according to the superchannel protocol. Usually this happens when non-super channel is used on the remote side or remote superchannel implementation has errors.

function GetDefaultResponse: string

GetTransportObject  protected

Returns itself.

function GetTransportObject: TObject

HaveGuid  protected virtual

This procedure calls the Connected method.

procedure HaveGuid

IncomingData  protected virtual abstract

Allows to perform additional actions when a package is received.

procedure IncomingData(Id: Integer; aData: TBytes)

Parameters:

  • Id: The package id received.
  • aData: The stream containing the incoming data, payload only.

ProcessOption  protected

Processes options that are received from the other sid

procedure ProcessOption(Data: TBytes)

Parameters:

  • Data:

SendError

Sends errorcode to the other side.

procedure SendError(Id: Integer; Error: Byte)

Parameters:

  • Id: The package id to use when sending data.
  • Error: The error code.

SendOptions  protected

Sends options to the other side.

procedure SendOptions(aData: string)

Parameters:

  • aData: The package content, in the string form.

SendPackage

Sends a package to the other side.

function SendPackage(aData: TStream; Id: Integer): IROPackageAck_Async

Parameters:

  • aData: The data to send, payload only.
  • Id: The package id to use, 0 may be passed to generate and use a new id.

SetAckDetails  protected virtual

procedure SetAckDetails(Id: Integer; Oke: Boolean; ErrorNo: Integer)

Parameters:

  • Id:
  • Oke:
  • ErrorNo:

SupportsOptions  protected

Checks for SkipAck and sends options to the other side.

procedure SupportsOptions

Descendants

See Also