Class TRtcConnection

Description
Hierarchy
Fields
Methods
Properties

Unit

Declaration

type TRtcConnection = class(TRtcComponent)

Description

Basic connection component wrapper

TRtcConnection is the Basic connection component wrapper (client & server). It publishes methods and handles all the tasks that are common to all connection components. All connection components are indirect descendants of TRtcConnection and therefor inherit all its methods and properties.

VERY IMPORANT!!! If you create connection components at runtime: * NEVER! use Create(), Free or Destroy on ANY connection component. * Allways use the 'NEW' class function (implemented by all TRtcConnection components) to create the connection object and * ONLY use the 'RELEASE' method to free the connection object.

MULTITHREADED CLIENT/SERVER:

When TRtcConnection.MultiThreaded property for this connection is True, your events will be called from within a Thread inside a Thread pool. If you decide to use your component(s) in a multithreaded environment, you have to keep in mind that all Data is being sent and received in the background, from threads belonging to the RTC Thread Pool. This implementation is thoroughly tested and works perfectly in any mulithreaded environment (tested on a dual-processor machine with thousands of clients accessing the server at the same time). But, to keep the code working for you, you will have to follow a few simple rules.

1. Accessing the component in MultiThreaded mode:

A) After a connection is initiated ('Connect' was called), your code which needs to access any methods or properties of that component, HAS TO BE synchronized with any background threads that might be using the component to process background requests.

The easiest way to work with any TRtcConnection component in a multithreaded mode is to implement everything as events. There are enough event handlers declared, so that most of the things can be done this way.

The mechanism integrated into TRtcConnection components makes sure that events triggered by the connection component DO NOT OVERLAP with callback functions and messages called by Windows. This means that you can safely use the component from ANY EVENT you define for that component. When the event is triggered, you are the owner of the component and nothing will access the component during your event execution.

B) But, there will probably be situations where you do not want to wait for a connection event in order to do something with your connection.

To be able to access the connection components from anywhere else than your event handlers (for example, from a Button click event), even when they are running in multithreaded mode, you will use TRtcConnection components ability to POST A JOB to itself.

All actions that TRtcConnection components do, are defined by small jobs that have to be executed. When there are no jobs waiting for execution, there are no Threads or CPU resources used.

Jobs are objects that contain DATA AND EXECUTION CODE. You can create jobs by extending the TRtcJob class and implementing your classes Run and SingleUse methods (defined as abstract by TRtcJob). After creating an instance of your TRtcJob class and initializing it with the data you need to execute the Run method, you can post your job object to your connection component by using the PostJob method (also implemented by TRtcConnection).

2. Accessing the GUI from events in MultiThreaded mode:

All events which have to access the GUI (Graphical User Interface, containing any visual component) and use components in Multi-Threaded mode HAVE TO be synchronized with the Main Thread by using the 'Sync' method.

If the "Sync" method is called from any RTC Thread, the Event passed as a parameter will be called from the Main Thread, puting the background thread (from which you called Sync) in a waiting state, until the Event finishes. When finished, the "Sync" method will return TRUE.

If the "Sync" method is called from the Main Thread, it will do nothing and immediately return TRUE.

You can also use the "inMainThread" method to check if your code is currently running inside the Main Thread.

Here is one 'Access GUI from OnDataReceived event' example:

procedure TMyForm.ServerOnDataReceived(Sender:TRtcConnection); begin // If we are currently inside any RTC background Thread, // the "Sync" method will post the event we specify in the 1st parameter // to the Main Thread, wait for that Event to finish and then return TRUE. // If we are already in the Main Thread, // the Sync method does nothing and returns FALSE.

// By using the following construct at the top of our event, we can // make sure that any code executed below will be running in the Main Thread.

if Sender.Sync(ServerOnDataReceived) then Exit;

// Since we are calling EXIT in case the "Sync" method returned TRUE // and we using our own even as the 1st parameter in the "Sync" method, // any code executed from this point will be running in the Main Thread. end;

This OnDataReceived event handler example wants to have GUI access throughout the event execution, so it will use the "Sync" method to call itself synchronized from the Main Thread in case it was called from a background RTC thread, then EXIT if the call was successful.

Naturaly, for events which do not need to access the GUI, you can simply implement the event without using the "Sync" method.

Hierarchy

Overview

Methods

Public constructor Create(AOwner:TComponent); override;
Public destructor Destroy; override;
Public procedure ReleaseProvider;
Public function TimedOut: boolean;
Public function isExtension:boolean; virtual;
Public function isConnected:boolean; virtual;
Public function isConnecting:boolean; virtual;
Public function isListening:boolean; virtual;
Public function isServer:boolean; virtual;
Public function isClient:boolean; virtual;
Public procedure Release;
Public procedure Check; virtual;
Public procedure AfterManualRead; virtual;
Public procedure Disconnect; virtual;
Public function isClosing:boolean; virtual;
Public function PeerAddr:RtcString; virtual;
Public function PeerPort:RtcString; virtual;
Public function LocalAddr:RtcString; virtual;
Public function LocalPort:RtcString; virtual;
Public function sPeerAddr:String; deprecated;
Public function sPeerPort:String; deprecated;
Public function sLocalAddr:String; deprecated;
Public function sLocalPort:String; deprecated;
Public procedure SkipRequests; virtual;
Public procedure CancelRequests; virtual;
Public function RequestCount:integer; virtual;
Public function TotalConnectionCount:integer; virtual;
Public function TotalClientConnectionCount:integer; virtual;
Public function TotalServerConnectionCount:integer; virtual;
Public function PostJob(var myJob; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;
Public function PostJobTo(Thr:TRtcThread; var myJob; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;
Public function PostEvent(Evnt:TRtcNotifyEvent; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;
Public function PostEventTo(Thr:TRtcThread; Evnt:TRtcNotifyEvent; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;
Public function Thread:TRtcThread; virtual;
Public function Sync(Event:TRtcNotifyEvent):boolean; overload;
Public function Sync(Event:TRtcErrorEvent; Err:Exception):boolean; overload;
Public function Sync(Event:TRtcFunctionCallEvent; Par:TRtcFunctionInfo; Res:TRtcValue):boolean; overload;
Public function Sync(Event:TRtcFunctionErrorEvent; Par:TRtcFunctionInfo; Res:TRtcValue; E:Exception; var Handled:boolean):boolean; overload;
Public function Sync(Event:TRtcResultEvent; Data:TRtcValue; Res:TRtcValue):boolean; overload;
Public function Sync(Event:TRtcResultErrorEvent; Data:TRtcValue; Res:TRtcValue; E:Exception):boolean; overload;
Public function Sync(Event:TRtcFunctionPrepareEvent; Data:TRtcValue):boolean; overload;
Public function Sync(Event:TRtcUserEvent; Obj:TObject):boolean; overload;
Public function Sync(Event:TRtcUserDataEvent; Obj:TObject; Data:TRtcValue):boolean; overload;
Public function Sync(Event:TRtcCustomEvent; Obj:TObject):boolean; overload;
Public function Sync(Event:TRtcCustomDataEvent; Obj:TObject; Data:TRtcValue):boolean; overload;
Public function Sync(Event:TRtcObjectCreateEvent; Param:TRtcObjectCall):boolean; overload;
Public function State:TRtcConnectionState;
Public function inMainThread:boolean;
Public function inThread:boolean; virtual;
Public procedure Accept; virtual;
Public function FindSession(const ID:RtcString):boolean; virtual;
Public function HaveSession(const ID:RtcString):boolean; virtual;
Public procedure UnLockSession; virtual;
Public procedure OpenSession(LockType:TRtcSessionLockType=sesFwdLock); virtual;
Public function CloseSession(const ID:RtcString):boolean; virtual;
Public function TotalSessionsCount:cardinal; virtual;
Public function TotalSessionsLocked:cardinal; virtual;
Public function TotalSessionsUnlocked:cardinal; virtual;
Public procedure ActivateObjectManager(xCreate:boolean=True); virtual;
Public function GetObjectManager:TRtcRemoteObjectManager; virtual;
Public function Read:RtcString; virtual;
Public procedure Write(const s:RtcString); overload; virtual;
Public procedure Write; overload;
Public function ReadEx:RtcByteArray; virtual;
Public procedure WriteEx(const s:RtcByteArray); overload; virtual;
Public function PeekEx:RtcByteArray; virtual;
Public procedure PokeEx(const s:RtcByteArray); virtual;
Public procedure Flush; virtual;
Public procedure WriteHeader(SendNow:boolean=True); overload; virtual;
Public procedure WriteHeader(const HeaderText: RtcString; SendNow:boolean=True); overload; virtual;
Public function sServerAddr:String; deprecated;
Public function sServerPort:String; deprecated;
Public function wsClearSendingQueue:boolean; overload;
Public function wsDisconnect:boolean; overload;
Public function wSend(iFrame:TRtcWSFrame; const iName:RtcWideString=''):boolean; overload;
Public function wSendMore(iFrame:TRtcWSFrame; const vPayload:RtcString; vFinal:boolean=False):boolean; overload;
Public function wSendMore(iFrame:TRtcWSFrame; const vPayload:RtcByteArray; vFinal:boolean=False):boolean; overload;
Public function wSend(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):boolean; overload;
Public function wSend(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;
Public function wSend(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;
Public function wSendIfIdle(iFrame:TRtcWSFrame; const iName:RtcWideString=''):boolean; overload;
Public function wSendIfIdle(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):boolean; overload;
Public function wSendIfIdle(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;
Public function wSendIfIdle(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;
Public function wsFirst:RtcIntPtr;
Public function wsNext(id:RtcIntPtr):RtcIntPtr;
Public function wsPrior(id:RtcIntPtr):RtcIntPtr;
Public function wsLast:RtcIntPtr;
Public function wsCount:integer;
Public function wSend(id:RtcIntPtr; iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;
Public function wSendMore(id:RtcIntPtr; iFrame:TRtcWSFrame; const vPayload:RtcByteArray; vFinal:boolean=False):integer; overload;
Public function wSendMore(id:RtcIntPtr; iFrame:TRtcWSFrame; const vPayload:RtcString; vFinal:boolean=False):integer; overload;
Public function wSend(id:RtcIntPtr; vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;
Public function wSend(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSend(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendIfIdle(id:RtcIntPtr; iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;
Public function wSendIfIdle(id:RtcIntPtr; vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;
Public function wSendIfIdle(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendIfIdle(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendToAll(iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;
Public function wSendToAll(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;
Public function wSendToAll(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendToAll(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendToIdle(iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;
Public function wSendToIdle(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;
Public function wSendToIdle(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendToIdle(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendToOthers(xid:RtcIntPtr; iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;
Public function wSendToOthers(xid:RtcIntPtr; vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;
Public function wSendToOthers(xid:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wSendToOthers(xid:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;
Public function wsDisconnect(id:RtcIntPtr):integer; overload;
Public function wsDisconnectAll:integer;
Public function wsClearSendingQueue(id:RtcIntPtr):integer; overload;
Public function wsClearAllSendingQueues:integer;
Public function wsGetID:RtcIntPtr;

Properties

Public property DataOut: cardinal read FDataOut;
Public property DataIn: cardinal read FDataIn;
Public property ReadCount: int64 read FReadCount;
Public property WriteCount: int64 read FWriteCount;
Public property OverLimit: boolean read FOverLimit write FOverLimit;
Public property Info: TRtcInfo read FInfo;
Public property Session: TRtcSession read GetSession;
Public property TimeoutsOfAPI: TRtcTimeoutsOfAPI read FTimeoutsOfAPI write SetTimeoutsOfAPI;
Public property Request: TRtcRequest read GetRequest write SetRequest;
Public property Response: TRtcResponse read GetResponse write SetResponse;
Public property RequestInserted: boolean read GetRequestInserted;
Public property ReconnectOn: TRtcReconnectParam read GetReconnectOn write SetReconnectOn;
Public property RestartOn: TRtcRestartParam read GetRestartOn write SetRestartOn;
Public property isWebSocket: boolean read FWebSocket;
Public property wsManager: TRtcWSManager read FWS;
Public property wsTemp[constiName:RtcWideString]: TRtcWSFrame read ws_GetTemp write ws_SetTemp;
Public property wsFrame[constiName:RtcWideString]: TRtcWSFrame read ws_GetFrame write ws_SetFrame;
Public property wsFrameOUT: TRtcWSFrame read FWSFrameOUT;
Public property wsFrameIN: TRtcWSFrame read ws_GetFrameIn;
Published property MultiThreaded: boolean read FMultiThread write SetMultiThread default False;
Published property Timeout: TRtcTimeout read FTimeout write SetTimeout;
Published property ServerAddr: RtcString read FAddr write FAddr;
Published property ServerPort: RtcString read FPort write FPort;
Published property ServerIPV: RtcIPV read FIPV write FIPV default rtc_IPVDefault;
Published property OnConnecting: TRtcNotifyEvent read FOnConnecting write FOnConnecting;
Published property OnDisconnecting: TRtcNotifyEvent read FOnDisconnecting write FOnDisconnecting;
Published property OnConnect: TRtcNotifyEvent read FOnConnect write FOnConnect;
Published property OnDisconnect: TRtcNotifyEvent read FOnDisconnect write FOnDisconnect;
Published property OnException: TRtcErrorEvent read FOnException write FOnException;

Description

Methods

Public constructor Create(AOwner:TComponent); override;

DO NOT CALL THIS CONSTRUCTOR DIRECTLY!!! Use the 'NEW' class function to create a new object!!!

Public destructor Destroy; override;

DO NOT CALL THIS DESTRUCTOR DIRECTLY!!! DO NOT CALL 'FREE' DIRECTLY!!! Use the Release method to destroy this object.

Public procedure ReleaseProvider;

Release the connection provider

Public function TimedOut: boolean;

Returns TRUE if connection was closed because of a Timeout (set using the "Timeout" property).

Public function isExtension:boolean; virtual;

ISAPI SERVER: Returns TRUE if this is a Server connection running as an extension or a plug-in to another Server.

OTHER: Always returns FALSE.

Public function isConnected:boolean; virtual;

CLIENT: Returns TRUE if Client is CONNECTED and ready to send/receive data.

SERVER: Always returns FALSE.

Public function isConnecting:boolean; virtual;

CLIENT: Returns TRUE if Client is Connected, Connecting or waiting to start the next RECONNECT attempt.

SERVER: Always returns FALSE.

Public function isListening:boolean; virtual;

SERVER: Returns TRUE if this is a Server listener and it is listening.

CLIENT: Always returns FALSE.

Public function isServer:boolean; virtual;

SERVER: Returns TRUE.

CLIENT: Returns FALSE.

Public function isClient:boolean; virtual;

SERVER: Returns TRUE if this is a Server-side connection opened by a CLIENT, Returns FALSE if this is the Server listener.

CLIENT: Always returns FALSE.

Public procedure Release;

If you create connection components at runtime, allways use the 'NEW' class function to create the connection object and 'RELEASE' procedure to free the connection object.

To make the code you write compatible with all new versions of Delphi, and to make sure that object is not released while it is still being used by internal connection component mechanisms, ONLY USE this 'Release' procedure to free any connection component and release all the resources that are used by the component.

After calling Release, you should also set the variable to NIL, in which you have stored the connection component.

Public procedure Check; virtual;

All native RTC connection components know when they get disconnected from peer and also trigger the events required.

But, there may be some third-party connection components coming, which will not know when a connection was closed by peer (for example, different implementations of blocking TCP/IP).

The Check method is here to cover such cases and give the connection provider means to write a method for checking if the connection is still active. In such cases, after calling the Check procedure, if the connection is still active, nothing will happen. But if the connection is dead, connection will be closed by the connection provider.

Public procedure AfterManualRead; virtual;

When using "Request.ManualRead=TRUE" or "Response.ManualRead=TRUE", make sure to call this method as the last line of the event where the Read method was used - if it was not called from "OnDataReceived".

Public procedure Disconnect; virtual;

*1.) If this is a listening connection, stop listening and close all connections open to this listener (gracefuly). All events that need to be triggered will be triggered.

*2.) If this is a client connection (initiated by this or the other side), close the connection (gracefuly). All events that need to be triggered will be triggered.

Public function isClosing:boolean; virtual;

Is the connection in the process of closing (disconnecting)? Do not try to send any more data out if this is True.

Public function PeerAddr:RtcString; virtual;

Get this connection's Peer Address (to which Address/IP are we connected?)

Public function PeerPort:RtcString; virtual;

Get this connection's Peer Port (to which Port are we connected?)

Public function LocalAddr:RtcString; virtual;

Get this connection's Local Address (on which local IP are we?)

Public function LocalPort:RtcString; virtual;

Get this connection's Local Port (on which local Port are we?)

Public function sPeerAddr:String; deprecated;

Warning: this symbol is deprecated.

(String) Get this connection's Peer Address.

Public function sPeerPort:String; deprecated;

Warning: this symbol is deprecated.

(String) Get this connection's Peer Port.

Public function sLocalAddr:String; deprecated;

Warning: this symbol is deprecated.

(String) Get this connection's Local Address.

Public function sLocalPort:String; deprecated;

Warning: this symbol is deprecated.

(String) Get this connection's Local Port.

Public procedure SkipRequests; virtual;

HTTP/DATA CLIENT: Skip all requests (RequestAborted events will NOT BE triggered!!!).

OTHER: Not supported - raises an Exception if called!

Public procedure CancelRequests; virtual;

HTTP/DATA CLIENT: Cancel all requests (will fire all RequestAborted events).

OTHER: Not supported - raises an Exception if called!

Public function RequestCount:integer; virtual;

HTTP/DATA CLIENT: Check request count (number of requests waiting to be processed).

OTHER: Not supported - always returns 0.

Public function TotalConnectionCount:integer; virtual;

Return the total number of active connections, counting all connections that are opened to this process by any TRtcConnection class (all servers and clients).

Public function TotalClientConnectionCount:integer; virtual;

Return the number of active connections, open by our Client connection components.

Public function TotalServerConnectionCount:integer; virtual;

Return the number of active connections, open to our Servers connection components.

Public function PostJob(var myJob; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;

Post a job to connection thread's job queue.

Parameters
Job
- If using existing connection components (not extenting them), 'Job' object has to be of TRtcJob type, or else the 'Unknown Job' exception will be raised from within the thread, which will close the connection.
Public function PostJobTo(Thr:TRtcThread; var myJob; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;

Post a job to "Thr" thread's job queue.

Parameters
Job
- If using existing connection components (not extenting them), 'Job' object has to be of TRtcJob type, or else the 'Unknown Job' exception will be raised from within the thread, which will close the connection.
Public function PostEvent(Evnt:TRtcNotifyEvent; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;

Post a job to call the envent "Evnt" from connection thread's job queue, passing this connection component as the "Sender" parameter to the event.

Public function PostEventTo(Thr:TRtcThread; Evnt:TRtcNotifyEvent; HighPriority:boolean=False; ForceThread:boolean=False):boolean; virtual;

Post a job to call the envent "Evnt" from "Thr" thread's job queue, passing this connection component as the "Sender" parameter to the event.

Public function Thread:TRtcThread; virtual;

Get connection component's virtual thread

Public function Sync(Event:TRtcNotifyEvent):boolean; overload;

If we are currently inside any RTC background thread, the "Sync" method will call the 'Event' synchronized from the Main Thread, wait for the event to finish and then returns TRUE. If we are already in the Main Thread, the "Sync" method does nothing and returns FALSE. You can use this method at the top of any RTC events which have to access the GUI (Graphical User Interface, everything visual). If you want to check wether your event is being executed from inside the Main Thread, you can use the inMainThread method.

Parameters
Event
- TRtcNotifyEvent method to be called synchronized, from the Main Thread.
Returns

True if the call was succesful

Public function Sync(Event:TRtcErrorEvent; Err:Exception):boolean; overload;

Same as Sync(Event), with a difference that you can synchronize TRtcErrorEvent events with this call and 'Err' will be used as the Exception parameter when calling the 'Event'.

Parameters
Event
- TRtcErrorEvent method to be called synchronized, from the MainThread
Err
- Exception object to be passed to the event
Returns

True if the call was succesful

Public function Sync(Event:TRtcFunctionCallEvent; Par:TRtcFunctionInfo; Res:TRtcValue):boolean; overload;

Same as Sync(Event), with a difference that you can synchronize TRtcFunctionCallEvent events with this call and 'Param' and 'Res' will be passed as parameters when calling the 'Event'.

Parameters
Event
- TRtcFunctionCallEvent method to be called synchronized, from the MainThread
Par
- TRtcFunctionCall object, containing all function call information
Res
- TRtcValue object, ready to receive the result information
Returns

True if the call was succesful

Public function Sync(Event:TRtcFunctionErrorEvent; Par:TRtcFunctionInfo; Res:TRtcValue; E:Exception; var Handled:boolean):boolean; overload;

Same as Sync(Event), with a difference that you can synchronize TRtcFunctionErrorEvent events with this call and 'Param', 'Res', 'E' and 'Handled' will be passed as parameters.

Parameters
Event
- TRtcFunctionErrorEvent method to be called synchronized, from the MainThread
Par
- TRtcFunctionCall object, containing all function call information
Res
- TRtcValue object, ready to receive the result information
E
- Exception object
Handled
- set to TRUE if the Exception is now handled
Returns

True if the call was succesful

Public function Sync(Event:TRtcResultEvent; Data:TRtcValue; Res:TRtcValue):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcResultEvent events with this call and 'Res' will be passed as the result parameter when calling the 'Event'.

Parameters
Event
- TRtcResultEvent method to be called synchronized, from the MainThread
Data
- TRtcValue object, containing the information which was sent to the server, which has produced the "Res"
Res
- TRtcValue object, containing the result information
Returns

True if the call was succesful

Public function Sync(Event:TRtcResultErrorEvent; Data:TRtcValue; Res:TRtcValue; E:Exception):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcResultEvent events with this call and 'Res' will be passed as the result parameter when calling the 'Event'.

Parameters
Event
- TRtcResultErrorEvent method to be called synchronized, from the MainThread
Data
- TRtcValue object, containing the information which was sent to the server, which has produced the "Res"
Res
- TRtcValue object, containing the result information
E
- Exception object, containing the exception raised
Returns

True if the call was succesful

Public function Sync(Event:TRtcFunctionPrepareEvent; Data:TRtcValue):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcFunctionPrepareEvent events with this call and 'Data' will be passed as the Data parameter when calling the 'Event'.

Parameters
Event
- TRtcFunctionPrepareEvent method to be called synchronized, from the MainThread
Data
- TRtcValue object, which you should use to prepare the remote function call
Returns

True if the call was succesful

Public function Sync(Event:TRtcUserEvent; Obj:TObject):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcUserEvent events with this call and the 'Obj' parameter will be passed to the 'Event'.

Parameters
Event
- TRtcUserEvent method to be called synchronized, from the Main Thread.
Obj
- Object to be passed as parameter to the event
Returns

True if the call was succesful

Public function Sync(Event:TRtcUserDataEvent; Obj:TObject; Data:TRtcValue):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcUserDataEvent events with this call and the 'Obj' and 'Data' parameters will be passed to the 'Event'.

Parameters
Event
- TRtcUserDataEvent method to be called synchronized, from the Main Thread.
Obj
- Object to be passed as parameter to the event
Data
- Value object to be passed as parameter to the event
Returns

True if the call was succesful

Public function Sync(Event:TRtcCustomEvent; Obj:TObject):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcCustomEvent events with this call and the 'Obj' parameter will be passed to the 'Event'.

Parameters
Event
- TRtcCustomEvent method to be called synchronized, from the Main Thread.
Obj
- Object to be passed as parameter to the event
Returns

True if the call was succesful

Public function Sync(Event:TRtcCustomDataEvent; Obj:TObject; Data:TRtcValue):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcCustomDataEvent events with this call and the 'Obj' and 'Data' parameters will be passed to the 'Event'.

Parameters
Event
- TRtcCustomDataEvent method to be called synchronized, from the Main Thread.
Obj
- Object to be passed as parameter to the event
Data
- Value object to be passed as parameter to the event
Returns

True if the call was succesful

Public function Sync(Event:TRtcObjectCreateEvent; Param:TRtcObjectCall):boolean; overload;

Same as Sync(Event), with the difference that you can synchronize TRtcObjectCreateEvent events with this call and 'Param' parameter will be passed to the 'Event'.

Parameters
Event
- TRtcObjectCreateEvent method to be called synchronized, from the Main Thread.
Param
- Object Constructor parameters
Returns

True if the call was succesful

Public function State:TRtcConnectionState;

Check current connection state. There is no real need to use this property to check your connection state, since events will be triggered when the state changes.

Public function inMainThread:boolean;

You can use this method to check if you are inside the Main thread, from which drawing and writing to the GUI is allowed. If true, you can directly access the GUI. If false, you have to use the Sync() method to call this or some other event synchronized, from where you can use the drawing routines.

Public function inThread:boolean; virtual;

You can use this method to check if your connection object is currently inside its Thread. If true, jobs do not have to be posted, they can be called directly. To check if you are allowed to access GUI (drawing or writing to the screen or canvas), use the inMainThread function.

Public procedure Accept; virtual;

HTTP/DATA SERVER: Request handler has to call Accept before it starts processing the request, so that all further events remain mapped to the active event handlers and don't switch before a reply has been sent.

OTHER: Not supported - raises an Exception if called!

Public function FindSession(const ID:RtcString):boolean; virtual;

HTTP/DATA SERVER: Find an existing Session with this ID. If Session with this ID does not exist, or session has expired or session is currently locked, returns FALSE. Otherwise, prepares the Session variable for use and returns TRUE.

OTHER: Not supported - raises an Exception if called!

Public function HaveSession(const ID:RtcString):boolean; virtual;

HTTP/DATA SERVER: If there is a session with this ID, returns TRUE, even if that session is locked.

OTHER: Not supported - raises an Exception if called!

Public procedure UnLockSession; virtual;

HTTP/DATA SERVER: If you do not need the Session anymore and do not want to keep the session locked until request completes, you can release the Session Lock by calling "UnLockSession". After this call, you will no longer have access to the Session object, until you lock it again using FindSession.

OTHER: Not supported - raises an Exception if called!

Public procedure OpenSession(LockType:TRtcSessionLockType=sesFwdLock); virtual;

HTTP/DATA SERVER: Create a new Session, with a new and unique Session ID.

OTHER: Not supported - raises an Exception if called!

Public function CloseSession(const ID:RtcString):boolean; virtual;

HTTP/DATA SERVER: If there is a Session with this "ID", returns TRUE and closes the session.

OTHER: Not supported - raises an Exception if called!

Public function TotalSessionsCount:cardinal; virtual;

HTTP/DATA SERVER: Total number of open Sessions.

OTHER: Not supported - always returns 0.

Public function TotalSessionsLocked:cardinal; virtual;

HTTP/DATA SERVER: Total number of Sessions currently locked. A session is locked after a call to FindSession() and unlocked after the Event is done executing.

OTHER: Not supported - always returns 0.

Public function TotalSessionsUnlocked:cardinal; virtual;

HTTP/DATA SERVER: Total number of Sessions currently unlocked. A session is locked after a call to FindSession() and unlocked after the Event is done executing.

OTHER: Not supported - always returns 0.

Public procedure ActivateObjectManager(xCreate:boolean=True); virtual;

HTTP/DATA SERVER: Activate current Session's Object Manager for use in the current Thread. Call with "False" as parameter if the Object Manager should already exist, or with "True" if a new Object Manager should be created if it wasn't already and a new Session opened if no Session is currently active.

OTHER: Not supported - raises an Exception if called!

Public function GetObjectManager:TRtcRemoteObjectManager; virtual;

HTTP/DATA SERVER: Returns the "Linked Objects" Manager of the currently active Session. Returns NIL if the active Session does NOT have an "Object Manager" assigned or if no Session was activated for the current request.

OTHER: Not supported - raises an Exception if called!

Public function Read:RtcString; virtual;

Read function used to read a String of byte-sized characters received. It may ONLY be called from inside your OnDataReceived event handler. Its behavior depends on the connection component that implements it.

Public procedure Write(const s:RtcString); overload; virtual;

Write function used to send a String of byte-sized characters out. Its behavior depends on the connection component that implements it.

Public procedure Write; overload;

Write function used to force sending HTTP header out.

Public function ReadEx:RtcByteArray; virtual;

ReadEx function is used to read raw byte data received. It may ONLY be called from inside your OnDataReceived event handler. Its behavior depends on the connection component that implements it.

Public procedure WriteEx(const s:RtcByteArray); overload; virtual;

WriteEx function used to send raw byte data out. Its behavior depends on the connection component that implements it.

Public function PeekEx:RtcByteArray; virtual;

PeekEx function can be used to access reading buffers containing raw content byte data received, without removing the content body from receiving buffers, allowing PeekEx to be used any number of times without breaking any code which requires access to that content and making it useful for content logging and monitoring, but ... the PeekEx method may ONLY be use from inside OnDataReiceved, OnPeekRequest and OnPeekResponse events. It also HAS TO be used BEFORE any calls to the Read or ReadEx, because these methods will clear reading buffers!

Public procedure PokeEx(const s:RtcByteArray); virtual;

"PokeEx" procedure can be used to REPLACE the content currently stored in reading buffers, making this new content accessible to anyone calling the next "PeekEx", "Read" or "ReadEx" method. "PokeEx" method may ONLY be use from inside "OnDataReiceved", "OnPeekRequest" and "OnPeekResponse" events.

Public procedure Flush; virtual;

HTTP/DATA CLIENT & SERVER: Flush all buffered data.
When using 'Write' without calling 'WriteHeader' before, all data prepared by calling 'Write' will be buffered until your event returns to its caller (automatically upon your event completion) or when you first call 'Flush'.
Flush will check if Request/Response.ContentLength is set and if not, will set the content length to the number of bytes buffered.
Flush does nothing if WriteHeader was called for this response.

OTHER: Not supported - call will be ignored.

Public procedure WriteHeader(SendNow:boolean=True); overload; virtual;

HTTP/DATA CLIENT & SERVER: Send Request/Response Headers out.

OTHER: Not supported - raises an Exception if called!

Public procedure WriteHeader(const HeaderText: RtcString; SendNow:boolean=True); overload; virtual;

HTTP/DATA CLIENT & SERVER: You can call WriteHeader with empty 'HeaderText' parameter to tell the component that you do not want any HTTP header to be sent.

OTHER: Not supported - raises an Exception if called!

Public function sServerAddr:String; deprecated;

Warning: this symbol is deprecated.

(String) Returns Server Address to connect to for the Client, or Listening address (Bind) for the Server.

Public function sServerPort:String; deprecated;

Warning: this symbol is deprecated.

(String) Returns Port on the Host to connect to for the Client, or Listening Port (Bind) for the Server.

Public function wsClearSendingQueue:boolean; overload;

WEB SOCKET: Clear this Web Socket connections "Sending Queue". Returns TRUE if this is a Web Socket connection (sending queue will be cleared), or FALSE if this is NOT a Web Socket connection or the connection is already closed.

Public function wsDisconnect:boolean; overload;

WEB SOCKET: Disconnect this Web Socket connection. If this is NOT an upgraded Web Socket connection, this method call is ignored. Returns TRUE if this is an established Web Socket connection (it will be closed), or FALSE if this call has failed (not a Web Socket connection or already closed).

Public function wSend(iFrame:TRtcWSFrame; const iName:RtcWideString=''):boolean; overload;

WEB SOCKET: Add Frame "iFrame" to this connections sending queue.

If called with iName<>'', the "iFrame" object will be stored as "Frame[iName]" in this component and will be available as "Sender.Frame[iName]" in all RTC events.

By using Send, this component becomes the *Owner* of the "iFrame" object. The "iFrame" object will be managed and destroyed by the component! Any external pointers or references to this object should be set to NIL.

Returns TRUE if "iFrame" object was added, or FALSE if this call has failed, but the "iFrame" object should NOT be used after this call in either case!

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendMore(iFrame:TRtcWSFrame; const vPayload:RtcString; vFinal:boolean=False):boolean; overload;

WEB SOCKET: Add more "Payload" data to "iFrame", which has already been placed into the sending queue and is now being sent or is waiting in the queue. Call with "vFinal=TRUE" if this is the final Payload for this Frame. Returns TRUE if "vPayload" was added to "iFrame", FALSE if this call failed.

Public function wSendMore(iFrame:TRtcWSFrame; const vPayload:RtcByteArray; vFinal:boolean=False):boolean; overload;

WEB SOCKET: Add more "Payload" data to "iFrame", which has already been placed into the sending queue and is now being sent or is waiting in the queue. Call with "vFinal=TRUE" if this is the final Payload for this Frame. Returns TRUE if "vPayload" was added to "iFrame", FALSE if this call failed.

Public function wSend(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):boolean; overload;

WEB SOCKET: Add a new Frame to this connections sending queue, initialized with: Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (with a randomly generated "MaskingKey"), everything else = 0.

This method call is identical to Send( TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns TRUE if the Frame was added to the sending queue, FALSE if this call failed.

Public function wSend(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;

WEB SOCKET: Add a new Frame to this connections sending queue, initialized with: Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to Send( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns TRUE if the Frame was added to the sending queue, FALSE if this call failed.

Public function wSend(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;

WEB SOCKET: Add a new Frame to this connections sending queue, initialized with: Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True),PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToAll( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns TRUE if the Frame was added to the sending queue, FALSE if this call failed.

Public function wSendIfIdle(iFrame:TRtcWSFrame; const iName:RtcWideString=''):boolean; overload;

WEB SOCKET: Add Frame "iFrame" to this connections sending queue, but ONLY if this connections sending queue is EMPTY and NOTHING is being sent out through the connection.

If called with iName<>'', the "iFrame" object will be stored as "Frame[iName]" in this component and will be available as "Sender.Frame[iName]" in all RTC events.

By using Send, this component becomes the *Owner* of the "iFrame" object. The "iFrame" object will be managed and destroyed by the component! Any external pointers or references to this object should be set to NIL.

Returns TRUE if "iFrame" object was added, or FALSE if this call has failed, but the "iFrame" object should NOT be used after this call in either case!

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendIfIdle(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):boolean; overload;

WEB SOCKET: Add a new Frame to this connections sending queue, initialized with the values listed below, but ONLY if this connections sending queue is EMPTY and NOTHING is currently being sent out through this connection:

Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections(with a randomly generated "MaskingKey"), everything else is 0.

This method call is identical to Send( TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns TRUE if the Frame was added to the sending queue, FALSE if this call failed.

Public function wSendIfIdle(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;

WEB SOCKET: Add a new Frame to this connections sending queue, initialized with the values listed below, but ONLY if this connections sending queue is EMPTY and NOTHING is currently being sent out through this connection:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to Send( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns TRUE if the Frame was added to the sending queue, FALSE if this call failed.

Public function wSendIfIdle(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):boolean; overload;

WEB SOCKET: Add a new Frame to this connections sending queue, initialized with the values listed below, but ONLY if NOTHING is currently being sent through this connection and the sending queue is empty:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToAll( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns TRUE if the Frame was added to the sending queue, FALSE if this call failed.

Public function wsFirst:RtcIntPtr;

WEB SOCKET MANAGER: First connection (ID, 0 = no connections)

Public function wsNext(id:RtcIntPtr):RtcIntPtr;

WEB SOCKET MANAGER: Next connection (ID, 0 = no more connecitons)

Public function wsPrior(id:RtcIntPtr):RtcIntPtr;

WEB SOCKET MANAGER: Prior connection (ID, 0 = no more connections)

Public function wsLast:RtcIntPtr;

WEB SOCKET MANAGER: Last connection (ID, 0 = no connections)

Public function wsCount:integer;

WEB SOCKET MANAGER: Connection count

Public function wSend(id:RtcIntPtr; iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;

WEB SOCKET MANAGER: Add Frame "iFrame" to the SENDING QUEUE of the connection "id".

The "iFrame" object used in this call will be destroyed immediately if this call fails, or auto-freed by the connection component if the call succeeds.

If called with iName<>'', the "iFrame" object will be stored as "Frame[iName]" in the connection component and available as "Sender.Frame[iName]" in all RTC events.

By using SendTo, the conneciton component becomes the *Owner* of the "iFrame" object, which means that the "iFrame" object will be managed and destroyed by the connection. All pointers and references to this object should be set to NIL after this call.

Returns 1 if "iFrame" object was added to the queue, or 0 if this call fails.

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendMore(id:RtcIntPtr; iFrame:TRtcWSFrame; const vPayload:RtcByteArray; vFinal:boolean=False):integer; overload;

WEB SOCKET MANAGER: Add more "Payload" data to "iFrame", which has already been placed into the sending queue for connection "id" and is now being sent our waiting to be sent. Call with "vFinal=TRUE" if this is the final Payload for this Frame. Returns 1 if "vPayload" was added to "iFrame", or 0 if this call failed.

Public function wSendMore(id:RtcIntPtr; iFrame:TRtcWSFrame; const vPayload:RtcString; vFinal:boolean=False):integer; overload;

WEB SOCKET MANAGER: Add more "Payload" data to "iFrame", which has already been placed into the sending queue for connection "id" and is now being sent our waiting to be sent. Call with "vFinal=TRUE" if this is the final Payload for this Frame. Returns 1 if "vPayload" was added to "iFrame", or 0 if this call failed.

Public function wSend(id:RtcIntPtr; vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connection "id", initialized with:

Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections(with a randomly generated "MaskingKey"), everything else is 0.

This method call is identical to Send(id, TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns 1 if the Frame was added to the queue, or 0 if this call has failed.

Public function wSend(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connection "id", initialized with:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to Send(id, TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns 1 if the Frame was added to the queue, or 0 if this call has failed.

Public function wSend(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connection "id", initialized with:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to Send(id, TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns 1 if the Frame was added to the queue, or 0 if this call has failed.

Public function wSendIfIdle(id:RtcIntPtr; iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;

WEB SOCKET MANAGER: Add Frame "iFrame" to the SENDING QUEUE of the connection "id", but ONLY if NOTHING is being sent through connection 'id' and the sending queue of connection "id" is EMPTY.

The "iFrame" object used in this call will be destroyed immediately if this call fails, or auto-freed by the connection component if the call succeeds.

If called with iName<>'', the "iFrame" object will be stored as "Frame[iName]" in the connection component and available as "Sender.Frame[iName]" in all RTC events.

By using SendTo, the conneciton component becomes the *Owner* of the "iFrame" object, which means that the "iFrame" object will be managed and destroyed by the connection. All pointers and references to this object should be set to NIL after this call.

Returns 1 if "iFrame" object was added to the queue, or 0 if this call fails.

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendIfIdle(id:RtcIntPtr; vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connection "id", initialized with the values listed below, but ONLY if NOTHING is being sent through connection 'id' and the sending queue of connection 'id' is EMPTY:

Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections(with a randomly generated "MaskingKey"), everything else is 0.

This method call is identical to SendIfIdle(id, TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns 1 if the Frame was added to the queue, or 0 if this call has failed.

Public function wSendIfIdle(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connection "id", initialized with the values listed below, but ONLY if NOTHING is being sent through connection 'id' and the sending queue of connection 'id' is EMPTY:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendIfIdle(id, TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns 1 if the Frame was added to the queue, or 0 if this call has failed.

Public function wSendIfIdle(id:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connection "id", initialized with the values listed below, but ONLY if NOTHING is being sent through connection 'id' and the sending queue of connection 'id' is EMPTY:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendIfIdle(id, TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns 1 if the Frame was added to the queue, or 0 if this call has failed.

Public function wSendToAll(iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;

WEB SOCKET MANAGER: Add Frame "iFrame" to the SENDING QUEUE of all connections managed here. The original "iFrame" object is destroyed automatically by this method call.

If called with iName<>'', a copy of "iFrame" will be created for every connection component and stored in the "Frame[iName]" property and available in all events triggered by the connection component, where it will be accessible using "Sender.Frame[iName]" and will be managed (and destroyed) by the "Sender.Frame" property.

Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendToAll(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of all managed connections, initialized with the following values:

Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections(with a randomly generated "MaskingKey"), everything else is 0.

This method call is identical to SendToAll( TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

Public function wSendToAll(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of all managed connection, initialized with the following values:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToAll( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

Public function wSendToAll(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of all managed connections, initialized with the following values:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToAll( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

Public function wSendToIdle(iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;

WEB SOCKET MANAGER: Add Frame "iFrame" to the SENDING QUEUE of all connections managed by this Web Socket Manager where NOTHING is being sent and the sending queue is EMPTY.

The original "iFrame" object is destroyed automatically by this method call.

If called with iName<>'', a copy of "iFrame" will be created for every connection component and stored in the "Frame[iName]" property and available in all events triggered by the connection component, where it will be accessible using "Sender.Frame[iName]" and will be managed (and destroyed) by the "Sender.Frame" property.

Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendToIdle(vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connections managed by this Web Socket Manager where NOTHING is being sent and the sending queue is EMPTY, initialized with the following values:

Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections(with a randomly generated "MaskingKey"), with everything else set to 0.

This method call is identical to SendToIdle( TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

Public function wSendToIdle(vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connections managed by this Web Socket Manager where NOTHING is being sent and the sending queue is EMPTY, initialized with the following values:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToIdle( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

Public function wSendToIdle(vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of connections managed by this Web Socket Manager where NOTHING is being sent and the sending queue is EMPTY, initialized with the following values:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToIdle( TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns the number of connections where this Web Socket Frame was added to the sending queue, or 0 if this call has failed.

Public function wSendToOthers(xid:RtcIntPtr; iFrame:TRtcWSFrame; const iName:RtcWideString=''):integer; overload;

WEB SOCKET MANAGER: Add Frame "iFrame" to the SENDING QUEUE of all connections managed by this Web Socket Manager, but NOT to the connection "xid" (send to all except "xid").

The "iFrame" object used in this call will be destroyed immediately if this call fails, or auto-freed by the connection component if the call succeeds.

If called with iName<>'', the "iFrame" object will be stored as "Frame[iName]" in the connection component and available as "Sender.Frame[iName]" in all RTC events.

By using SendTo, the conneciton component becomes the *Owner* of the "iFrame" object, which means that the "iFrame" object will be managed and destroyed by the connection. All pointers and references to this object should be set to NIL after this call.

Returns the number of connections where the "iFrame" object was added to the queue, or 0 if this call has failed.

NOTE: The "iFrame.Masked" property is automatically set to TRUE and the "iFrame.MaskingKey" property is randomly generated if the Frame object is being added to the sending queue of a Client-side connection component. On all Frames added to the sending queue of a Server-side connections, the "iFrame.Masked" property will be automatically set to FALSE and the "iFrame.MaskingKey" property will be cleared to all zeroes.

Public function wSendToOthers(xid:RtcIntPtr; vOpcode:Rtc4Bit; vFinal:boolean=True; vPayloadLength:int64=0):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of all connections managed by this Web Socket Manager, but NOT to the connection "xid" (send to all except "xid"), initialized with the following values:

Opcode:="vOpcode", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=0), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections(with a randomly generated "MaskingKey"), everything else is 0.

This method call is identical to SendToOthers(id, TRtcWSFrame.Create(vOpcode,vFinal,vPayloadLength) ). Returns the number of connections where this Frame was added to the queue, or 0 if this call failed.

Public function wSendToOthers(xid:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcString; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of all connections managed by this Web Socket Manager, but NOT to the connection "xid" (send to all except "xid"), initialized with the following values:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToOthers(id, TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns the number of connections where this Frame was added to the queue, or 0 if this call failed.

Public function wSendToOthers(xid:RtcIntPtr; vOpcode:Rtc4Bit; const vPayload:RtcByteArray; vFinal:Boolean=True; vPayloadLength:int64=-1):integer; overload;

WEB SOCKET MANAGER: Add a new Web Socket Frame to the SENDING QUEUE of all connections managed by this Web Socket Manager, but NOT to the connection "xid" (send to all except "xid"), initialized with the following values:

Opcode:="vOpcode", Payload = "vPayload", Final:="vFinal" (default=True), PayloadLength:="vPayloadLength" (default=length(vPayload)), Masked := "FALSE" for Server-side connections or "TRUE" for Client-side connections (randomly generated "MaskingKey"), everything else = 0.

This method call is identical to SendToOthers(id, TRtcWSFrame.Create(vOpcode,vPayload,vFinal,vPayloadLength) ). Returns the number of connections where this Frame was added to the queue, or 0 if this call failed.

Public function wsDisconnect(id:RtcIntPtr):integer; overload;

WEB SOCKET MANAGER: Disconnect the Web Socket connection "id". Returns 1 if a connection with "id" was found (and will be closed), or 0 if this call has failed (connection could not be found).

Public function wsDisconnectAll:integer;

WEB SOCKET MANAGER: Disconnect all Web Socket connections managed here. Returns the number of connections found (and now being closed), or 0 if this call has failed (no connections found).

Public function wsClearSendingQueue(id:RtcIntPtr):integer; overload;

WEB SOCKET MANAGER: Clear the SENDING QUEUE for the Web Socket connection "id". Returns 1 if a connection with "id" was found (queued Frames will be removed), or 0 if this call has failed (connection could not be found). This does NOT cancel Web Socket Frames already being SENT out. It only removes Web Socket Frames waiting in the queue!

Public function wsClearAllSendingQueues:integer;

WEB SOCKET MANAGER: Clear the SENDING QUEUES of all Web Socket connections managed here. Returns 1 if a connection with "id" was found (queued Frames will be removed), or 0 if this call has failed (connection could not be found). This does NOT cancel Web Socket Frames already being SENT out. It only removes Web Socket Frames waiting in the queue!

Public function wsGetID:RtcIntPtr;

WEB SOCKET MANAGER: If this connection is managed by a Web Socket Manager, the "WSGetID" method returns the "ID" of this connnection in our Web Socket Manager, which can be used with all "WS*" methods which require an "id" as the 1st parameter.

Properties

Public property DataOut: cardinal read FDataOut;

DataOut (Read-Only) can be used from the OnDataOut event, to check how much data has now been sent out. The value of this property changes with every OnDataOut event and should only be read from your OnDataOut event handler.

Public property DataIn: cardinal read FDataIn;

DataIn (Read-Only) can be used from the OnDataIn event, to check how much data has just arrived. The value of this property changes with every OnDataIn event and should only be read from your OnDataIn event handler.

Public property ReadCount: int64 read FReadCount;

Total number of bytes read from the other side (Peer/Remote) through this connection.

Public property WriteCount: int64 read FWriteCount;

Total number of bytes sent to the other side (Peer/Remote) through this connection.

Public property OverLimit: boolean read FOverLimit write FOverLimit;

This property will be set to TRUE if the connection was established, even though our connection limit was reached (or over the limit).

You can check the number of total conncetions open using the TotalConnectionCount function. If you find this connection should stay open (even though the limit was reached when it connected), change this property to FALSE, to handle it like any other connection.

Note: This property is not being used by any TRtcConnection component or its descendants. It is only intended for your use. Even if the overLimit property is TRUE, it will not affect this connection's behavior.

Public property Info: TRtcInfo read FInfo;

Additional connection component information.

You can use this property as you see fit. The only purpose of the Info property is to give the component user ways to store additional information about this conncetion inside the connection component itself, without having to create and maintain separate data structures.

Public property Session: TRtcSession read GetSession;

HTTP/DATA SERVER: Current Request's Session info. Before you can access the Session for the Request, you have to find the appropriate Session by using the FindSession function or create a new session by calling the OpenSession method.

HTTP/DATA CLIENT: This connection's Session info. If you will be using multiple client connections and need to store session information, you have to start a separate session for every client connection.

There is a difference between this DataClient's Session object and the DataServer's Session object. DataClient's Session object stays permamently defined all the time, from the point of object creation to its destruction.

OTHER: Not supported - raises an Exception if accessed!

Public property TimeoutsOfAPI: TRtcTimeoutsOfAPI read FTimeoutsOfAPI write SetTimeoutsOfAPI;

You can set all timeout parameters for the clients underlying API connection or default timeout periods for all client connections of the server connection component using this property. Check TRtcTimeoutsOfAPI for more information.

Public property Request: TRtcRequest read GetRequest write SetRequest;

HTTP/DATA CLIENT & SERVER: Access to current request information. Use Request property to prepare the request header. Here you can set all header variables and parameters. If there is no content body to send out (only header), you will at least have to call 'WriteHeader' or 'Write' without parameters once.

OTHER: Not supported - raises an Exception if accessed!

Public property Response: TRtcResponse read GetResponse write SetResponse;

HTTP/DATA CLIENT & SERVER: Access to current response information. Use Response property to read the response information received. Here is all the info that was available in response header. To read response's body, use the Read function.

OTHER: Not supported - raises an Exception if accessed!

Public property RequestInserted: boolean read GetRequestInserted;

HTTP/DATA CLIENT: Another request has just been inserted before this one?

OTHER: Not supported - always returns FALSE.

Public property ReconnectOn: TRtcReconnectParam read GetReconnectOn write SetReconnectOn;

CLIENT: By setting properties in ReconnectOn to True, you do not have to do anything special to initiate a Reconnect after specific events occur.

OTHER: Not supported - raises an Exception if accessed!

Public property RestartOn: TRtcRestartParam read GetRestartOn write SetRestartOn;

SERVER: By setting properties in RestartOn to True, you do not have to do anything special to initiate a renewed Listen after specific events occure. For more information, check TRtcRestartParam.

OTHER: Not supported - raises an Exception if accessed!

Public property isWebSocket: boolean read FWebSocket;

WEB SOCKET: Is this an upgraded Web Socket connection?

Public property wsManager: TRtcWSManager read FWS;

WEB SOCKET MANAGER: Web Socket Manager where this connection is being managed. Assigned automatically by the first Web Socket Manager where this connection was added and cleared automatically by the same Web Socket Manager when the connection is removed.

Public property wsTemp[constiName:RtcWideString]: TRtcWSFrame read ws_GetTemp write ws_SetTemp;

WEB SOCKET: "wsTemp" property can be used to store pointers to TRtcWSFrame objects currently used for processing Web Socket Frames which are already stored in a connection component and should NOT be auto-freed here!

Public property wsFrame[constiName:RtcWideString]: TRtcWSFrame read ws_GetFrame write ws_SetFrame;

WEB SOCKET: "wsFrame" property is used to store named TRtcWSFrame objects currently used for sending or receiving Web Socket Frames, which should be auto-freed by this connection component.

Public property wsFrameOUT: TRtcWSFrame read FWSFrameOUT;

WEB SOCKET: "FrameOUT" property gives you direct access to the currently active Web Socket Frame object used for SENDING out Web Socket data, even if the Send() method was used with an empty "iName" parameter.

This property may ONLY be used from inside events triggered by this connection component. If this property returns NIL, it means that all Web Socket Frames have been sent and the Web Socket SENDING QUEUE is curently empty (done sending).

Public property wsFrameIN: TRtcWSFrame read ws_GetFrameIn;

WEB SOCKET: "FrameIN" property gives you direct access to the currently active Web Socket Frame object used for READING received Web Socket data. Using this property automatically creates a new Frame object on first read access and reads all content from receiving buffers to prepare the Frame for usage, eliminating the need to manually create a TRtcWSFrame instance for read access, or to manually use connection components "Read" or "ReadEx" method in combination with Frames "wfWrite" or "wfWriteEx" method to prepare the Frame for reading. This is an auto-created and auto-freed Frame object which is stored separately without a "Name".

Published property MultiThreaded: boolean read FMultiThread write SetMultiThread default False;

Set the MultiThreaded property to True if you want your connection to use the Thread pooling mechanism, which is integrated into the RealThinClient library and can be used by all RTC connection components. To find out what more you need to keep in mind when working in multithreaded mode, check the TRtcConnection description.

NOTE: This property is read only before you call 'Listen' for the server component or 'Connect' for the client component. Changing this property when a connection is open will have no effect on the component, until the next time you start the listener or open a new connection.

WARNING: To safely use your components in MultiThreaded mode, also check the Descriptions for TRtcConnection, Sync, inMainThread, inThread and PostJob.

Published property Timeout: TRtcTimeout read FTimeout write SetTimeout;

You can set all timeout parameters for the client connection component or default timeout periods for all client connections of the server connection component using this property. Check TRtcTimeout for more information.

Published property ServerAddr: RtcString read FAddr write FAddr;

Server Address to connect to for the Client, Listening address (Bind) for the Server (leave empty to listen on all network cards).

Published property ServerPort: RtcString read FPort write FPort;

Server Port to connect to for the Client, Listening Port (Bind) for the Server (never leave empty).

Published property ServerIPV: RtcIPV read FIPV write FIPV default rtc_IPVDefault;

Server "IP Version" prefference

Published property OnConnecting: TRtcNotifyEvent read FOnConnecting write FOnConnecting;

This event will be called when a new connection is waiting to be initialized. This is still BEFORE a connection is ready to read/send data.

Published property OnDisconnecting: TRtcNotifyEvent read FOnDisconnecting write FOnDisconnecting;

This event will be called when a succesful connection is being closed.

Published property OnConnect: TRtcNotifyEvent read FOnConnect write FOnConnect;

This event will be called after a new connection has been succesfully established and is ready to be used. The event triggered will receive the client connection object as parameter.



* 1) If this was a client connection on which you called 'Connect' to attempt a new connection to a server, this event handler will be the first event to trigger after 'OnConnecting' and will receive the current connection object as parameter, only if the connection to the server was succesfull. If server was not available, 'OnConnectFail' event will be triggered instead. Also, in case of failure, the 'OnDisconnect' event will NOT be triggered.



* 2) If this was a listening connection (server), this event handler will receive a new connection object as parameter and be called directly after the 'OnClientConnect' and 'OnConnecting' events. In case needed, you can change all the actual events to be triggered for every client connection from the 'OnClientConnect' event handler. But, it is not advisable to do so. It is better to have 1 event handler for all client connections that belong to a specific server and use the 'Sender' parameter to distinguish between different clients.

Published property OnDisconnect: TRtcNotifyEvent read FOnDisconnect write FOnDisconnect;

This event will be called when a prior working connection (for which you have allready received the OnConnect event) just got disconnected, by either side:
1.) You closed it by calling Disconnect, or
2.) the other side closed it, or
3.) the connection simply colapsed.

Published property OnException: TRtcErrorEvent read FOnException write FOnException;

This event is used to process exceptions that happen in the background, for example while sending data from buffer to the other side.

Normaly, no exceptions should happen in the background. If an exception happens in the background and you set the event handler for the OnException event, you would receive the exception object, so you can handle it if needed (for example, write it to a Log file).

If there is no handler for this event, background exceptions will be ignored.


Generated by PasDoc 0.14.0.