Unit GenericServerConnection; { This is a common interface used to connect to the server. The simplest implementation is a TCP/IP socket. The interface is based on that. However, other implementations exist. Note that all of the proxy settings and such are pushed to this unit. Other units will pull these settings from the GetAlertsData unit. This unit was intented to work at a much lower level than that unit. In principal this unit could be used for in other programs. } Interface Type TGenericServerConnection = Class; TGenericServerConnectionCallback = Procedure(Connection : TGenericServerConnection) Of Object; TGenericServerMsgConnectionCallback = Procedure(Connection : TGenericServerConnection; Msg : String) Of Object; TGenericServerConnection = Class Protected FSocksServer, FSocksPort, FSocksUsercode, FSocksPassword, FSocksLevel : String; FProxyUserName, FProxyPassword, FProxyServer : String; FProxyPort : Integer; FTimeoutMs : Integer; FOnSessionClosed, FOnSessionConnected, FOnDataAvailable : TGenericServerConnectionCallback; FOnAutoRetry : TGenericServerMsgConnectionCallback; FConnectionErrorMessage : String; Public // You can only call this once. You can get callbacks as soon as you // call this procedure, even before it returns. This returns true on // success. On failure it returns false, and leaves information for // the end user in ConnectionErrorMessage. Function Connect : Boolean; Virtual; Abstract; // You can only call this after an OnSessionConnected callback. Procedure SendStr(S : String); Virtual; Abstract; Procedure Close; Virtual; Abstract; Function GetAll : String; Virtual; Abstract; // These should only be set before the call to connect. // Socks Property SocksServer : String Read FSocksServer Write FSocksServer; Property SocksPort : String Read FSocksPort Write FSocksPort; Property SocksUsercode : String Read FSocksUsercode Write FSocksUsercode; Property SocksPassword : String Read FSocksPassword Write FSocksPassword; Property SocksLevel : String Read FSocksLevel Write FSocksLevel; // HTTP Property ProxyUserName : String Read FProxyUserName Write FProxyUserName; Property ProxyPassword : String Read FProxyPassword Write FProxyPassword; Property ProxyServer : String Read FProxyServer Write FProxyServer; Property ProxyPort : Integer Read FProxyPort Write FProxyPort; Property TimeoutMs : Integer Read FTimeoutMs Write FTimeoutMs; // This is always called, even if there are errors. Property OnSessionClosed : TGenericServerConnectionCallback Read FOnSessionClosed Write FOnSessionClosed; // This is only called on a successful connection. (Or at least one that // appears to be connected.) Property OnSessionConnected : TGenericServerConnectionCallback Read FOnSessionConnected Write FOnSessionConnected; Property OnDataAvailable : TGenericServerConnectionCallback Read FOnDataAvailable Write FOnDataAvailable; // This allows us to send a yellow tickmark to the display when there is // an error even though we are handling the error ourselves. Property OnAutoRetry : TGenericServerMsgConnectionCallback Read FOnAutoRetry Write FOnAutoRetry; Property ConnectionErrorMessage : String Read FConnectionErrorMessage; End; Implementation End.