Unit rtcGateConst

Description
Uses
Classes, Interfaces, Objects and Records
Functions and Procedures
Types
Constants
Variables

Description

Gateway Constants - Copyright 2004-2018 (c) Teppi Technology (https://rtc.teppi.net)

Global parameters required by the Gateway and Gate Client components.

Overview

Classes, Interfaces, Objects and Records

Name Description
Class ERtcOutOfBounds  

Functions and Procedures

function Int2Bytes(UID:Cardinal):RtcByteArray;
function Bytes2Int(const BAR:RtcByteArray; loc:integer=0):Cardinal;
function crcGateCmd2Bytes(Cmd:byte; UID:Cardinal):RtcByteArray;
function crcBytes2GateCmd(var Cmd:byte; const BAR:RtcByteArray; loc:integer=0):Cardinal;
function crcGateID2Bytes(UID:Cardinal):RtcByteArray;
function crcBytes2GateID(const BAR:RtcByteArray; loc:integer=0):Cardinal;
function Word2Bytes(UID:Word):RtcByteArray;
function Bytes2Word(const BAR:RtcByteArray; loc:integer=0):Word;
function crcInt2Bytes(UID:Cardinal):RtcByteArray;
function crcBytes2Int(const BAR:RtcByteArray; loc:integer=0):Cardinal;
function OneByte2Bytes(UID:Byte):RtcByteArray;
function Bytes2OneByte(const BAR:RtcByteArray; loc:integer=0):Byte;
function GetAppRunTime:TAppRunTime;
procedure SetupConnectionTimeouts(Sender:TRtcConnection);

Types

TGateUID = RtcIntPtr;
TAppRunTime = int64;

Constants

RUN_TIMER_PRECISION = 1000;
RUN_TIMER_DAY_LENGTH = 24*60*60*RUN_TIMER_PRECISION;
MinLowID=TGateUID(1);
MinHigID=TGateUID(111111);
MaxHigID=TGateUID(999999);
CntLowIDs=MinHigID-MinLowID;
CntHigIDs=MaxHigID-MinHigID;
MinUserID = MinLowID;
MaxUserID = MaxHigID;
errNoUID = 0;
errBadUID = MaxUserID+1;
errBadCRC = MaxUserID+2;
GroupIDMask=Cardinal($FFF);
UserIDShift=12;
UserIDMask =Cardinal($FFFFF) shl UserIDShift;
MinInternalUserID = MinUserID shl UserIDShift;
MaxInternalUserID = MaxUSerID shl UserIDShift;
MinGID=1;
MaxGID=GroupIDMask;
MinInternalUserGroupID = MinInternalUserID + MinGID;
MaxInternalUserGroupID = MaxInternalUserID + MaxGID;
Cmd_SendData = $F0;
Cmd_AddUserToGroup = $E1;
Cmd_RemoveUserFromGroup = $D2;
Cmd_RemoveGroup = $C3;
Cmd_SendAll = $F0;
Cmd_SendFirst = $E1;
Cmd_SendMore = $D2;
Cmd_SendLast = $C3;
Cmd_Send_AllG = $FC;
Cmd_Send_FirstG = $ED;
Cmd_Send_MoreG = $DE;
Cmd_Send_LastG = $CF;
Cmd_UserIn = $B4;
Cmd_UserOut = $A5;
Cmd_UserOn = $96;
Cmd_UserOff = $87;
Cmd_FriendAdd = $78;
Cmd_FriendRemove = $69;
Cmd_RemoveFriends = $5A;
Cmd_Subscribe = $4B;
Cmd_UnSubscribe = $3C;
Cmd_UserBeFriend = $5A;
Cmd_UserUnFriend = $4B;
Cmd_UserReady = $3C;
Cmd_UserNotReady = $2D;

Variables

GATECHECK_FRIEND4GROUPS:boolean=True;
LOG_GATEWAY_TIMEOUTS: boolean = False ;
LOG_GATEWAY_ERRORS: boolean = False ;
LOG_GATEWAY_STATUS: boolean = False ;
LOG_GATECLIENT_TIMEOUTS: boolean = False ;
LOG_GATECLIENT_EXITS: boolean = False ;
PING_INTERVAL_inMS:Cardinal = 100;
CLEAN_INTERVAL_inMS:Cardinal = 1000;
PING_PACKET_SIZE:byte=6;
SENDPING_INTERVAL:TAppRunTime = 10 * RUN_TIMER_PRECISION;
MAX_GATECLIENT_RECONNECT_WAIT:integer = 3;
GATEACCMAN_GROUPID_LOCK:TAppRunTime = 120 * RUN_TIMER_PRECISION;
GATEACCMAN_AUTHCODE_VALID:TAppRunTime = 180 * RUN_TIMER_PRECISION;
GATEACCMAN_AUTHCODE_DIGITS:byte = 9;
DEF_OUTSTREAM_SIZE:Cardinal = Cardinal(2000)*1000*1000;
DEF_GATEWAY_ACTIVEUSER_LIMIT:integer=100000;
DEF_GATEWAY_TOTALUSER_LIMIT:integer=200000;
CLIENTRELEASE_MAXWAIT:integer=30;
CLIENT_WAITFOR_CHECKSTATE:integer=100;
CLIENT_FORCED_RECONNECT:boolean=FALSE;
CLIENTCONNECT_TIMEOUT:TAppRunTime = 30 * RUN_TIMER_PRECISION;
CLIENTCHECKLOGIN_TIMEOUT:TAppRunTime = 60 * RUN_TIMER_PRECISION;
CLIENTCHECKLOGOUT_TIMEOUT:TAppRunTime = 180 * RUN_TIMER_PRECISION;
CLIENTCHECKIN_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;
CLIENTCHECKOUT_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;
CLIENTCHECKMAXIN_TIMEOUT:TAppRunTime = 45 * RUN_TIMER_PRECISION;
CLIENTCHECKMAXOUT_TIMEOUT:TAppRunTime = 45 * RUN_TIMER_PRECISION;
CLIENTCHECKRECV_TIMEOUT:TAppRunTime = 60 * RUN_TIMER_PRECISION;
CLIENTCHECKSEND_TIMEOUT:TAppRunTime = 60 * RUN_TIMER_PRECISION;
GATECHECKOPEN_TIMEOUT:TAppRunTime = 20 * RUN_TIMER_PRECISION;
GATECHECKIN_TIMEOUT:TAppRunTime = 25 * RUN_TIMER_PRECISION;
GATECHECKOUT_TIMEOUT:TAppRunTime = 25 * RUN_TIMER_PRECISION;
GATECHECKMAXIN_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;
GATECHECKMAXOUT_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;
GATECHECKRECV_TIMEOUT:TAppRunTime = 50 * RUN_TIMER_PRECISION;
GATECHECKSEND_TIMEOUT:TAppRunTime = 50 * RUN_TIMER_PRECISION;
GATECHECKCLOSE_TIMEOUT:TAppRunTime = 300 * RUN_TIMER_PRECISION;
GATECHECKLOGOUT_TIMEOUT:TAppRunTime = 360 * RUN_TIMER_PRECISION;
GATECHECKDONE_TIMEOUT:TAppRunTime = 600 * RUN_TIMER_PRECISION;
GATEACCOUNT_BIGKEY:boolean=True;
GATEACCOUNT_RANDSEED:integer=32;
GATEID_BIGKEY:boolean=False;
GATEID_RANDSEED:integer=64;
GATEACCOUNT_PRIVATE_RSAKEY_SIZE:integer=96;
GATEACCOUNT_PUBLIC_RSAKEY_SIZE:integer=64;
GATE_LOG:String='GATE';
GATE_OK_CODE:integer=200;
GATE_ERROR_CODE:integer=409;
GATE_ERROR_TEXT:RtcString='Conflict';
GATE_FATALERROR_CODE:integer=412;
GATE_FATALERROR_TEXT:RtcString='Precondition Failed';
GATEURI_STATUS:RtcString='$s';
GATEURI_PING:RtcString='$p';
GATEURI_LOGIN:RtcString='$l';
GATEURI_INPUT:RtcString='$i';
GATEURI_OUTPUT:RtcString='$o';
GATEURI_INPUTRESET:RtcString='$ir';
GATEURI_OUTPUTRESET:RtcString='$or';

Description

Functions and Procedures

function Int2Bytes(UID:Cardinal):RtcByteArray;
 
function Bytes2Int(const BAR:RtcByteArray; loc:integer=0):Cardinal;
 
function crcGateCmd2Bytes(Cmd:byte; UID:Cardinal):RtcByteArray;

in: UID (Cardinal = 32-bits) + Cmd (8 bits) out: 6 bytes = UID (4 bytes, high to low order) + Cmd (1 byte) + CRC (1 byte)

function crcBytes2GateCmd(var Cmd:byte; const BAR:RtcByteArray; loc:integer=0):Cardinal;

raises exception if CRC check fails

function crcGateID2Bytes(UID:Cardinal):RtcByteArray;

in: UID (1 .. 999999) out: 4 bytes = UID (3 bytes, high to low order) + CRC (1 byte)

function crcBytes2GateID(const BAR:RtcByteArray; loc:integer=0):Cardinal;

Returns the UserID if everything is OK, or ... - "errNoUID" if byte size missmatch - "errBadUID" if received UID out of range - "errBadCRC" if CRC check fails

function Word2Bytes(UID:Word):RtcByteArray;
 
function Bytes2Word(const BAR:RtcByteArray; loc:integer=0):Word;
 
function crcInt2Bytes(UID:Cardinal):RtcByteArray;
 
function crcBytes2Int(const BAR:RtcByteArray; loc:integer=0):Cardinal;
 
function OneByte2Bytes(UID:Byte):RtcByteArray;
 
function Bytes2OneByte(const BAR:RtcByteArray; loc:integer=0):Byte;
 
function GetAppRunTime:TAppRunTime;
 
procedure SetupConnectionTimeouts(Sender:TRtcConnection);

Set connection timeouts based on global GATE TIMEOUT values. Used internally by TRtcHttpGateClient components.

Types

TGateUID = RtcIntPtr;
 
TAppRunTime = int64;
 

Constants

RUN_TIMER_PRECISION = 1000;

GetAppRunTime Timer "ticks per second"

RUN_TIMER_DAY_LENGTH = 24*60*60*RUN_TIMER_PRECISION;

Number of GetAppRunTime "ticks per day"

MinLowID=TGateUID(1);
 
MinHigID=TGateUID(111111);
 
MaxHigID=TGateUID(999999);
 
CntLowIDs=MinHigID-MinLowID;
 
CntHigIDs=MaxHigID-MinHigID;
 
MinUserID = MinLowID;
 
MaxUserID = MaxHigID;
 
errNoUID = 0;
 
errBadUID = MaxUserID+1;
 
errBadCRC = MaxUserID+2;
 
GroupIDMask=Cardinal($FFF);
 
UserIDShift=12;
 
UserIDMask =Cardinal($FFFFF) shl UserIDShift;
 
MinInternalUserID = MinUserID shl UserIDShift;
 
MaxInternalUserID = MaxUSerID shl UserIDShift;
 
MinGID=1;
 
MaxGID=GroupIDMask;
 
MinInternalUserGroupID = MinInternalUserID + MinGID;
 
MaxInternalUserGroupID = MaxInternalUserID + MaxGID;
 
Cmd_SendData = $F0;

Client -> Gateway

Cmd_AddUserToGroup = $E1;
 
Cmd_RemoveUserFromGroup = $D2;
 
Cmd_RemoveGroup = $C3;
 
Cmd_SendAll = $F0;

Gateway -> Client

Cmd_SendFirst = $E1;
 
Cmd_SendMore = $D2;
 
Cmd_SendLast = $C3;
 
Cmd_Send_AllG = $FC;
 
Cmd_Send_FirstG = $ED;
 
Cmd_Send_MoreG = $DE;
 
Cmd_Send_LastG = $CF;
 
Cmd_UserIn = $B4;

Client <=> Gateway

Cmd_UserOut = $A5;
 
Cmd_UserOn = $96;
 
Cmd_UserOff = $87;
 
Cmd_FriendAdd = $78;
 
Cmd_FriendRemove = $69;
 
Cmd_RemoveFriends = $5A;

Client -> Gateway

Cmd_Subscribe = $4B;
 
Cmd_UnSubscribe = $3C;
 
Cmd_UserBeFriend = $5A;

Gateway -> Client

Cmd_UserUnFriend = $4B;
 
Cmd_UserReady = $3C;
 
Cmd_UserNotReady = $2D;
 

Variables

GATECHECK_FRIEND4GROUPS:boolean=True;

Should the Gateway check if a User who is being added to a User Group has registered the Owner of that Group as his Friend ?

If this value is FALSE, any User logged in to the Gateway could add any number of other Users to his User Group(s) and then use the Gateway to dispatch large amounts of data to all those Users, without asking for permission from the Users.

When this value is TRUE, before a User can add another User to his User Group, the user who is being added to the Group has to add the Group Owner as his Friend, preventing hackers from adding random Users to their Groups and flooding the Gateway.

LOG_GATEWAY_TIMEOUTS: boolean = False ;
 
LOG_GATEWAY_ERRORS: boolean = False ;
 
LOG_GATEWAY_STATUS: boolean = False ;
 
LOG_GATECLIENT_TIMEOUTS: boolean = False ;
 
LOG_GATECLIENT_EXITS: boolean = False ;
 
PING_INTERVAL_inMS:Cardinal = 100;

Ping check interval in milliseconds

CLEAN_INTERVAL_inMS:Cardinal = 1000;

Clean-up check interval in milliseconds

PING_PACKET_SIZE:byte=6;

Size of a PING packet in Bytes

SENDPING_INTERVAL:TAppRunTime = 10 * RUN_TIMER_PRECISION;

Send PING interval in AppRunTime ticks

MAX_GATECLIENT_RECONNECT_WAIT:integer = 3;

Maximum time (in Ping check intervals, default = seconds) to force a delay between Gate Client reconnect attempts

GATEACCMAN_GROUPID_LOCK:TAppRunTime = 120 * RUN_TIMER_PRECISION;

Gate Account Manager lock on recently deactivated Group IDs in "AppRunTime" ticks, default = 120 seconds (2 minutes)

GATEACCMAN_AUTHCODE_VALID:TAppRunTime = 180 * RUN_TIMER_PRECISION;

Number of seconds for the last "AuthCode" generated by the Gate Account Manager to stay valid (in "AppRunTime" ticks) Default value = 180 seconds (3 minutes)

GATEACCMAN_AUTHCODE_DIGITS:byte = 9;

Number of digits to use for "AuthCode" (default = 9), automatically generated by the Gate Account Manager

DEF_OUTSTREAM_SIZE:Cardinal = Cardinal(2000)*1000*1000;

Default size for the Output Stream, if not explicitly set by Client (2 GB)

DEF_GATEWAY_ACTIVEUSER_LIMIT:integer=100000;

Default limit for the max number of Active Users on the Gateway. 100.000 users = 10% of available User IDs

DEF_GATEWAY_TOTALUSER_LIMIT:integer=200000;

Default limit for the max number of Total Users on the Gateway 200.000 users = 20% of available User IDs

CLIENTRELEASE_MAXWAIT:integer=30;

Maximum time Gate Client components can wait for their internal connection components to get released before force-destroying them.

CLIENT_WAITFOR_CHECKSTATE:integer=100;

To make sure Threads will NOT be blocked infinitely while waiting for a signal to continue reading when using the WinInet or WinSock API (bocking), the "TRtcHtpGateClient" component will be manually checking its internal state at least once every "CLIENT_WAITFOR_CHECKSTATE" milliseconds.

CLIENT_FORCED_RECONNECT:boolean=FALSE;

Force an immediate Client re-connect attempt in case of any connection problems?

CLIENTCONNECT_TIMEOUT:TAppRunTime = 30 * RUN_TIMER_PRECISION;

Connection Timeout values ...

CLIENTCHECKLOGIN_TIMEOUT:TAppRunTime = 60 * RUN_TIMER_PRECISION;

0:30 to Connect

CLIENTCHECKLOGOUT_TIMEOUT:TAppRunTime = 180 * RUN_TIMER_PRECISION;

1:00 to Log in

CLIENTCHECKIN_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;

3:00 inactive timeout for Log out

CLIENTCHECKOUT_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;

0:35 for incoming packets

CLIENTCHECKMAXIN_TIMEOUT:TAppRunTime = 45 * RUN_TIMER_PRECISION;

0:35 for outgoing packets

CLIENTCHECKMAXOUT_TIMEOUT:TAppRunTime = 45 * RUN_TIMER_PRECISION;

0:45 max in packets

CLIENTCHECKRECV_TIMEOUT:TAppRunTime = 60 * RUN_TIMER_PRECISION;

0:45 max out packets

CLIENTCHECKSEND_TIMEOUT:TAppRunTime = 60 * RUN_TIMER_PRECISION;

1:00 receive timeout

GATECHECKOPEN_TIMEOUT:TAppRunTime = 20 * RUN_TIMER_PRECISION;

1:00 send timeout

GATECHECKIN_TIMEOUT:TAppRunTime = 25 * RUN_TIMER_PRECISION;

0:20 to open connection

GATECHECKOUT_TIMEOUT:TAppRunTime = 25 * RUN_TIMER_PRECISION;

0:25 for incoming packets

GATECHECKMAXIN_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;

0:25 for outgoing packets

GATECHECKMAXOUT_TIMEOUT:TAppRunTime = 35 * RUN_TIMER_PRECISION;

0:35 max in packets

GATECHECKRECV_TIMEOUT:TAppRunTime = 50 * RUN_TIMER_PRECISION;

0:35 max out packets

GATECHECKSEND_TIMEOUT:TAppRunTime = 50 * RUN_TIMER_PRECISION;

0:50 receive timeout

GATECHECKCLOSE_TIMEOUT:TAppRunTime = 300 * RUN_TIMER_PRECISION;

0:50 send timeout

GATECHECKLOGOUT_TIMEOUT:TAppRunTime = 360 * RUN_TIMER_PRECISION;

5:00 inactive timeout to close a connection

GATECHECKDONE_TIMEOUT:TAppRunTime = 600 * RUN_TIMER_PRECISION;

6:00 inactive timeout for Log out

GATEACCOUNT_BIGKEY:boolean=True;

10:00 inactive timeout for Removal Use BIG Private Keys for Gateway Accounts ?

GATEACCOUNT_RANDSEED:integer=32;

Random Seed size for Gateway Accounts

GATEID_BIGKEY:boolean=False;

Use BIG Keys for Public Account Manager IDs ?

GATEID_RANDSEED:integer=64;

Random Seed size for Public Account Manager IDs

GATEACCOUNT_PRIVATE_RSAKEY_SIZE:integer=96;

RSA Key strength for Private Gateway Accounts (96 octets = 768 bits)

GATEACCOUNT_PUBLIC_RSAKEY_SIZE:integer=64;

RSA Key strength for temporary Public Gateway Accounts (64 octets = 512 bits)

GATE_LOG:String='GATE';
 
GATE_OK_CODE:integer=200;
 
GATE_ERROR_CODE:integer=409;
 
GATE_ERROR_TEXT:RtcString='Conflict';
 
GATE_FATALERROR_CODE:integer=412;
 
GATE_FATALERROR_TEXT:RtcString='Precondition Failed';
 
GATEURI_STATUS:RtcString='$s';

$s, $p, $l, $i, $o, $ir & $or URIs are used by the Gateway

GATEURI_PING:RtcString='$p';
 
GATEURI_LOGIN:RtcString='$l';
 
GATEURI_INPUT:RtcString='$i';
 
GATEURI_OUTPUT:RtcString='$o';
 
GATEURI_INPUTRESET:RtcString='$ir';
 
GATEURI_OUTPUTRESET:RtcString='$or';
 

Generated by PasDoc 0.14.0.