TROSCClientWorker

Overview

This is the super channel worker class designed to use on the client side.
This class is used internally, users will never intercat with it.

Location

 

constructor Create (TROBaseSuperTcpConnection)    (declared in TROBaseSuperChannelWorker)

Creates the worker instance.

constructor Create(ABaseSuperConnection: TROBaseSuperTcpConnection)

Parameters:

  • ABaseSuperConnection: The connection object to be associated with the worker, TROBaseSuperConnection instance.

Creates a new instance with a supplied values.

constructor Create(aOwner: TROBaseSuperTCPChannel; aBaseSuperConnection: TROBaseSuperTcpConnection)

Parameters:

  • aOwner: The package id received.
  • aBaseSuperConnection: The stream containing the incoming data, payload only.

BaseSuperConnection  protected    (declared in TROBaseSuperChannelWorker)

Provides read-only access to the connection object (incoming or outgoing) that is paired with the worker object. The connection object is a TROBaseSuperConnection descendant and is assigned by the constructor.

property BaseSuperConnection: TROBaseSuperTcpConnection read

BeginWriteLock    (declared in TROBaseSuperChannelWorker)

Acquires a lock using the internal synchronization object, used to synchronize write access to the underlying socket.

procedure BeginWriteLock

ClientID    (declared in TROBaseSuperChannelWorker)

Gets or set the client unique identifer.

property ClientID: TGuid read write

Connected  protected override

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

procedure Connected

Disconnect    (declared in TROBaseSuperChannelWorker)

Instructs the connection object to disconnect.

procedure Disconnect

Disconnected  protected override

Sets the worker to disconnected state.

procedure Disconnected(var aRestartLoop: Boolean)

Parameters:

  • aRestartLoop: True value of this parameter indicates that the connection has to be reestablished.

DoExecute    (declared in TROBaseSuperChannelWorker)

The main processing method that is executed on a background thread.

procedure DoExecute

EndWriteLock    (declared in TROBaseSuperChannelWorker)

Releases a lock using the internal synchronization object, used to synchronize write access to the underlying socket.

procedure EndWriteLock

GenerateId    (declared in TROBaseSuperChannelWorker)

Used to generate a new package identifier in a thread safe manner. The package id is actually an order number of the data package (remote requests transmitted from clients to servers and events data transmitted from servers to clients) transmitted since the superchannel start. It increments from 1 to MaxInt for clients and decrements from -1 down to -MaxInt for servers. This method acquires a write lock prior to generate a new package id.

function GenerateId: Integer

GetDefaultResponse  protected virtual    (declared in TROBaseSuperChannelWorker)

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

Idle  protected override

This method is executed when the channel enters idle state: existing connection is disconnected and a new one is not established yet.

procedure Idle

IncomingData  protected override

Called to process protocol options agreement packages.

procedure IncomingData(aId: Integer; aData: TStream)

Parameters:

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

IntSendData  protected    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

function IntSendData(aId: Integer; aData: TStream): IROPackageAck

Parameters:

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

IsConnected    (declared in TROBaseSuperChannelWorker)

Allows to get or set the connected state flag that indicates wether the connection associated with the worker is established.

property IsConnected: Boolean read write

IsServer  protected    (declared in TROBaseSuperChannelWorker)

Allows to get or set the flag that allows to distinguish client side worker from server ones. The value for this flag is set once by the constructor code of the derived class and is used by the unified code that supports superchannel protocol.

property IsServer: Boolean read write

LastData  protected    (declared in TROBaseSuperChannelWorker)

Allows to get the last channel activity date and time. This value is reset every time the channel is about to send a data package or received one.

property LastData: TDateTime read

MaxPackageSize    (declared in TROBaseSuperChannelWorker)

Determines the maximum size of the package that can be transmitted through the channel. The worker code compares this value to the data size to be transmitted and throws an exception in case of oversize.

property MaxPackageSize: Integer read write

OnProgress    (declared in TROBaseSuperChannelWorker)

This event is fired while buffered data transmission is performed (IntSendData and ReadStream methods). The event is fired after each data portion transmitted.

property OnProgress: TProgressEvent read write
delegate: procedure OnProgress(aSender: TObject; aType: TProgressType; aDirection: TProgressDirection; aTransferred: Integer; aTotal: Integer)

Owner

Provides read-only access to the super channel instance that the worker works for.

property Owner: TROBaseSuperTCPChannel read

PingFrequency  protected    (declared in TROBaseSuperChannelWorker)

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    (declared in TROBaseSuperChannelWorker)

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    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

procedure ProcessOption(aData: TStream)

Parameters:

  • aData: The stream containing the options agreement package.

ReadStream  protected    (declared in TROBaseSuperChannelWorker)

Performs the buffered read from the associated connection object (finally from the socket).

function ReadStream(aDest: TStream; aLen: Integer): Boolean

Parameters:

  • aDest: The stream to place the data into.
  • aLen: The number of bytes to read.

SendError    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

procedure SendError(aId: Integer; aError: Byte)

Parameters:

  • aId: The package id received.
  • aError: The stream containing the incoming data, payload only.

SendOptions  protected    (declared in TROBaseSuperChannelWorker)

Sends the protocol options agreement package.

procedure SendOptions(aData: ROUTF8String)

Parameters:

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

SendPackage    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

function SendPackage(aData: TStream; aId: Integer): IROPackageAck

Parameters:

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

SetAckDetails  protected override

procedure SetAckDetails(aId: Integer; aOk: Boolean; aErrorNo: Integer)

Parameters:

  • aId:
  • aOk:
  • aErrorNo:

SkipAck    (declared in TROBaseSuperChannelWorker)

Defines whether "acknowledgement" messages are skipped.

property SkipAck: Boolean read write

SupportsOptions  protected    (declared in TROBaseSuperChannelWorker)

Called when the remote party initiates the protocol options agreement. Calls SendOptions to send the required options information.

procedure SupportsOptions

WaitForAck    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

class procedure WaitForAck(aPackage: IROPackageAck; aTimeout: Integer)

Parameters:

  • aPackage: The package id received.
  • aTimeout: The stream containing the incoming data, payload only.

 

BaseSuperConnection  protected    (declared in TROBaseSuperChannelWorker)

Provides read-only access to the connection object (incoming or outgoing) that is paired with the worker object. The connection object is a TROBaseSuperConnection descendant and is assigned by the constructor.

property BaseSuperConnection: TROBaseSuperTcpConnection read

ClientID    (declared in TROBaseSuperChannelWorker)

Gets or set the client unique identifer.

property ClientID: TGuid read write

IsConnected    (declared in TROBaseSuperChannelWorker)

Allows to get or set the connected state flag that indicates wether the connection associated with the worker is established.

property IsConnected: Boolean read write

IsServer  protected    (declared in TROBaseSuperChannelWorker)

Allows to get or set the flag that allows to distinguish client side worker from server ones. The value for this flag is set once by the constructor code of the derived class and is used by the unified code that supports superchannel protocol.

property IsServer: Boolean read write

LastData  protected    (declared in TROBaseSuperChannelWorker)

Allows to get the last channel activity date and time. This value is reset every time the channel is about to send a data package or received one.

property LastData: TDateTime read

MaxPackageSize    (declared in TROBaseSuperChannelWorker)

Determines the maximum size of the package that can be transmitted through the channel. The worker code compares this value to the data size to be transmitted and throws an exception in case of oversize.

property MaxPackageSize: Integer read write

Owner

Provides read-only access to the super channel instance that the worker works for.

property Owner: TROBaseSuperTCPChannel read

PingFrequency  protected    (declared in TROBaseSuperChannelWorker)

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    (declared in TROBaseSuperChannelWorker)

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

SkipAck    (declared in TROBaseSuperChannelWorker)

Defines whether "acknowledgement" messages are skipped.

property SkipAck: Boolean read write

 

WaitForAck    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

class procedure WaitForAck(aPackage: IROPackageAck; aTimeout: Integer)

Parameters:

  • aPackage: The package id received.
  • aTimeout: The stream containing the incoming data, payload only.

 

constructor Create (TROBaseSuperTcpConnection)    (declared in TROBaseSuperChannelWorker)

Creates the worker instance.

constructor Create(ABaseSuperConnection: TROBaseSuperTcpConnection)

Parameters:

  • ABaseSuperConnection: The connection object to be associated with the worker, TROBaseSuperConnection instance.

Creates a new instance with a supplied values.

constructor Create(aOwner: TROBaseSuperTCPChannel; aBaseSuperConnection: TROBaseSuperTcpConnection)

Parameters:

  • aOwner: The package id received.
  • aBaseSuperConnection: The stream containing the incoming data, payload only.

BeginWriteLock    (declared in TROBaseSuperChannelWorker)

Acquires a lock using the internal synchronization object, used to synchronize write access to the underlying socket.

procedure BeginWriteLock

Connected  protected override

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

procedure Connected

Disconnect    (declared in TROBaseSuperChannelWorker)

Instructs the connection object to disconnect.

procedure Disconnect

Disconnected  protected override

Sets the worker to disconnected state.

procedure Disconnected(var aRestartLoop: Boolean)

Parameters:

  • aRestartLoop: True value of this parameter indicates that the connection has to be reestablished.

DoExecute    (declared in TROBaseSuperChannelWorker)

The main processing method that is executed on a background thread.

procedure DoExecute

EndWriteLock    (declared in TROBaseSuperChannelWorker)

Releases a lock using the internal synchronization object, used to synchronize write access to the underlying socket.

procedure EndWriteLock

GenerateId    (declared in TROBaseSuperChannelWorker)

Used to generate a new package identifier in a thread safe manner. The package id is actually an order number of the data package (remote requests transmitted from clients to servers and events data transmitted from servers to clients) transmitted since the superchannel start. It increments from 1 to MaxInt for clients and decrements from -1 down to -MaxInt for servers. This method acquires a write lock prior to generate a new package id.

function GenerateId: Integer

GetDefaultResponse  protected virtual    (declared in TROBaseSuperChannelWorker)

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

Idle  protected override

This method is executed when the channel enters idle state: existing connection is disconnected and a new one is not established yet.

procedure Idle

IncomingData  protected override

Called to process protocol options agreement packages.

procedure IncomingData(aId: Integer; aData: TStream)

Parameters:

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

IntSendData  protected    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

function IntSendData(aId: Integer; aData: TStream): IROPackageAck

Parameters:

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

ProcessOption  protected    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

procedure ProcessOption(aData: TStream)

Parameters:

  • aData: The stream containing the options agreement package.

ReadStream  protected    (declared in TROBaseSuperChannelWorker)

Performs the buffered read from the associated connection object (finally from the socket).

function ReadStream(aDest: TStream; aLen: Integer): Boolean

Parameters:

  • aDest: The stream to place the data into.
  • aLen: The number of bytes to read.

SendError    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

procedure SendError(aId: Integer; aError: Byte)

Parameters:

  • aId: The package id received.
  • aError: The stream containing the incoming data, payload only.

SendOptions  protected    (declared in TROBaseSuperChannelWorker)

Sends the protocol options agreement package.

procedure SendOptions(aData: ROUTF8String)

Parameters:

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

SendPackage    (declared in TROBaseSuperChannelWorker)

Called to process protocol options agreement packages.

function SendPackage(aData: TStream; aId: Integer): IROPackageAck

Parameters:

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

SetAckDetails  protected override

procedure SetAckDetails(aId: Integer; aOk: Boolean; aErrorNo: Integer)

Parameters:

  • aId:
  • aOk:
  • aErrorNo:

SupportsOptions  protected    (declared in TROBaseSuperChannelWorker)

Called when the remote party initiates the protocol options agreement. Calls SendOptions to send the required options information.

procedure SupportsOptions

 

OnProgress    (declared in TROBaseSuperChannelWorker)

This event is fired while buffered data transmission is performed (IntSendData and ReadStream methods). The event is fired after each data portion transmitted.

property OnProgress: TProgressEvent read write
delegate: procedure OnProgress(aSender: TObject; aType: TProgressType; aDirection: TProgressDirection; aTransferred: Integer; aTotal: Integer)