TROIcsAsyncSuperChannelWorker

Overview

The TROIcsAsyncSuperChannelWorker class contains methods for sending/receiving data to/from clients. It implements the IROActiveEventServer interface to support event managing as well as the IROTCPTransport interface.

The TROIcsAsyncSuperChannelWorker is used internally by the TROIcsAsyncSuperTCPServer.

Location

Implements

 

constructor Create (IROAbstractTCPConnection)    (declared in TROAsyncSuperChannelWorker)

Creates a new instance.

constructor Create(aConnection: IROAbstractTCPConnection)

Parameters:

  • aConnection:

Creates a new instance.

constructor Create(AServer: TROCustomIcsAsyncSuperTCPServer; AClient: TROAsyncSuperTCPServerSocketClient)

Parameters:

  • AServer:
  • AClient:

ClientID    (declared in TROAsyncSuperChannelWorker)

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 override

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

procedure Connected

Connection    (declared in TROAsyncSuperChannelWorker)

Specifies the IROAbstractTCPConnection that was used in the constructor.

property Connection: IROAbstractTCPConnection read write

Disconnect    (declared in TROAsyncSuperChannelWorker)

Called to disconnect the current connection.

procedure Disconnect

Disconnected  protected override

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.

DispatchEvent  protected

This method is called by the event manager to notify the server about a new event.

procedure DispatchEvent(anEventDataItem: TROEventData; aSessionReference: TGUID; aSender: TObject)

Parameters:

  • anEventDataItem: Represents an event that fires.
  • aSessionReference: Unique identifier that represents the session.
  • aSender: Indicates the object that receives the event.

DoSetup    (declared in TROAsyncSuperChannelWorker)

Performs the initial initialization.

procedure DoSetup

EventsRegistered  protected

This method is called whenever the event manager registers for the specified client.

procedure EventsRegistered(aSender: TObject; aClient: TGUID)

Parameters:

  • aSender: Object that will receive the event.
  • aClient: GUID that specifies the client.

GenerateId    (declared in TROAsyncSuperChannelWorker)

Generates a package ID.

function GenerateId: Integer

GetDefaultResponse  protected override

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

Returns itself.

function GetTransportObject: TObject

HaveGuid  protected virtual    (declared in TROAsyncSuperChannelWorker)

This procedure calls the Connected method.

procedure HaveGuid

IncomingData  protected override

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

Specifies the current state.

property IsConnected: Boolean read write

IsServer  protected    (declared in TROAsyncSuperChannelWorker)

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

property IsServer: Boolean read write

LastData  protected    (declared in TROAsyncSuperChannelWorker)

Specifies the timestamp of the last operation.

property LastData: TDateTime read write

MaxPackageSize    (declared in TROAsyncSuperChannelWorker)

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

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 TROAsyncSuperChannelWorker)

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 TROAsyncSuperChannelWorker)

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

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

Sends options to the other side.

procedure SendOptions(aData: string)

Parameters:

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

SendPackage    (declared in TROAsyncSuperChannelWorker)

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

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

Parameters:

  • Id:
  • Oke:
  • ErrorNo:

SkipAck    (declared in TROAsyncSuperChannelWorker)

Defines whether "acknowledgement" messages are skipped.

property SkipAck: Boolean read write

SupportsOptions  protected    (declared in TROAsyncSuperChannelWorker)

Checks for SkipAck and sends options to the other side.

procedure SupportsOptions

WaitForAck    (declared in TROAsyncSuperChannelWorker)

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

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

Specifies the IROAbstractTCPConnection that was used in the constructor.

property Connection: IROAbstractTCPConnection read write

IsConnected    (declared in TROAsyncSuperChannelWorker)

Specifies the current state.

property IsConnected: Boolean read write

IsServer  protected    (declared in TROAsyncSuperChannelWorker)

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

property IsServer: Boolean read write

LastData  protected    (declared in TROAsyncSuperChannelWorker)

Specifies the timestamp of the last operation.

property LastData: TDateTime read write

MaxPackageSize    (declared in TROAsyncSuperChannelWorker)

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

property MaxPackageSize: Integer read write

PingFrequency  protected    (declared in TROAsyncSuperChannelWorker)

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 TROAsyncSuperChannelWorker)

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

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

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

Creates a new instance.

constructor Create(aConnection: IROAbstractTCPConnection)

Parameters:

  • aConnection:

Creates a new instance.

constructor Create(AServer: TROCustomIcsAsyncSuperTCPServer; AClient: TROAsyncSuperTCPServerSocketClient)

Parameters:

  • AServer:
  • AClient:

Connected  protected override

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

procedure Connected

Disconnect    (declared in TROAsyncSuperChannelWorker)

Called to disconnect the current connection.

procedure Disconnect

Disconnected  protected override

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.

DispatchEvent  protected

This method is called by the event manager to notify the server about a new event.

procedure DispatchEvent(anEventDataItem: TROEventData; aSessionReference: TGUID; aSender: TObject)

Parameters:

  • anEventDataItem: Represents an event that fires.
  • aSessionReference: Unique identifier that represents the session.
  • aSender: Indicates the object that receives the event.

DoSetup    (declared in TROAsyncSuperChannelWorker)

Performs the initial initialization.

procedure DoSetup

EventsRegistered  protected

This method is called whenever the event manager registers for the specified client.

procedure EventsRegistered(aSender: TObject; aClient: TGUID)

Parameters:

  • aSender: Object that will receive the event.
  • aClient: GUID that specifies the client.

GenerateId    (declared in TROAsyncSuperChannelWorker)

Generates a package ID.

function GenerateId: Integer

GetDefaultResponse  protected override

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

Returns itself.

function GetTransportObject: TObject

HaveGuid  protected virtual    (declared in TROAsyncSuperChannelWorker)

This procedure calls the Connected method.

procedure HaveGuid

IncomingData  protected override

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

Processes options that are received from the other sid

procedure ProcessOption(Data: TBytes)

Parameters:

  • Data:

SendError    (declared in TROAsyncSuperChannelWorker)

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

Sends options to the other side.

procedure SendOptions(aData: string)

Parameters:

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

SendPackage    (declared in TROAsyncSuperChannelWorker)

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

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

Parameters:

  • Id:
  • Oke:
  • ErrorNo:

SupportsOptions  protected    (declared in TROAsyncSuperChannelWorker)

Checks for SkipAck and sends options to the other side.

procedure SupportsOptions