Indy 9
|
TIdDICTServer = class(TIdTCPServer)
The Dictionary Server Protocol (DICT) is a TCP transaction based query/response protocol that allows a client to access dictionary definitions from a set of natural language dictionary databases.
TIdDICTServer uses an event-based architecture that provides event handlers for the following DICT protocol commands:
TIdDICTServer also provides the OnCommandOther event handler to respond to unknown DICT commands, or DICT protocol extensions.
TIdDICTServer does not provide an implementation of the event handlers. The application should assign procedures to the event handlers to respond to event notifications, or the result code 500 with the error message RSCMDNotRecognized will be generated.
property DefaultPort: integer;
constructor Create(AOwner: TComponent); override;
SeeAso: DefaultPort, IdPORT_DICT
property OnCommandAuth: TIdDICTAuthEvent;
Authentication is an optional server capability. The AUTH command may be implemented by a DICT server. Applications should assign a procedure to the event handler in order to respond to the DICT command, or the server will return the default message:
500 command not recognized
property OnCommandClient: TIdDICTShowEvent;
The CLIENT command allows the client to provide information about itself for possible logging and statistical purposes. All clients should send this command after connecting to the server. All DICT servers must implement this command, though, the server doesn't have to do anything with the information provided by the client.
Applications should assign a procedure to the event handler in order to respond to the DICT command, or the server will return the default message:
500 command not recognized
property OnCommandDefine: TIdDICTDefineEvent;
The DICT DEFINE command is used to perform a search for the specified word in the indicated database(s). Applications should assign a procedure to the event handler in order to respond to the DICT command, or the server will return the default message:
500 command not recognized
property OnCommandHelp: TIdDICTGetEvent;
The DICT HELP command provides a short summary of commands that are understood by this implementation of the DICT server. All DICT servers must implement the HELP command.
Applications should assign a procedure to the event handler in order to respond to the DICT command, or the server will return the default message:
500 command not recognized
property OnCommandMatch: TIdDICTMatchEvent;
The DICT MATCH command is used to search the dictionary index and report the words found using a particular strategy. All DICT servers must implement the MATCH command, and must support the "exact" and "prefix" strategies.
The "exact" strategy performs a case-insensitive comparison. The "prefix" strategy is similar to "exact", except that it only compares the first part of the word. These strategies are easily implemented and are generally the most useful. Other strategies are server dependent.
Other strategies that might be considered are matches based on substring, suffix, regular expressions, soundex [KNUTH73], and Levenshtein [PZ85] algorithms. These last two are especially useful for correcting spelling errors. Other useful strategies perform some sort of "reverse" lookup (i.e., by searching definitions to find the word that the query suggests).
Strategy may also contain the special character ".", which indicates that the server should use the default strategy for that server. This is usually a derivative of the Levenshtein algorithm [PZ85].
Database contains the name of the database to be searched, in a form returned by SHOW DB, or one the following wildcard characters:
Applications should assign a procedure to the event handler in order to respond to the DICT command, or the server will return the default message:
500 command not recognized
property OnCommandOption: TIdDICTOtherEvent;
At the current time, OPTION MIME is the only recognized option. In the future, standard extensions to this protocol should be proposed which allow the client to request certain content types or encodings.
OPTION MIME requests that all text responses be prefaced by a MIME header, as described in RFC2045, and followed by a single blank line (CRLF). If a client requests this option, then the client MUST be able to parse Content-Type and Content-transfer-encoding headers, and MUST be able to ignore textual responses which have an unsupported content or encoding. A client MUST support the UTF-8 encoding described in RFC2044.
OPTION MIME is a REQUIRED server capability, and all DICT servers MUST implement this command.
property OnCommandOther: TIdDICTOtherEvent;
property OnCommandQuit: TIdDICTGetEvent;
The DICT server must implement the QUIT command.
property OnCommandSASLAuth: TIdDICTAuthEvent;
OnCommandSASLAuth must provide, as parameters, the name of the user to be authenticated, and the BASE64-encoded initial SASL response as described in RFC 2045. All responses to the SASLAUTH server challenge should use the SASLRESP command and a BASE64-encoded parameter.
Authentication is an optional server capability. The SASLAUTH command may be implemented by a DICT server.
property OnCommandShow: TIdDICTShowEvent;
OnCommandShow must provide parameters that indicate the thread of execution performing the command, and the SHOW command parameters to be included in the command execution. The command options include:
property OnCommandStatus: TIdDICTGetEvent;
The STATUS command returns server-specific timing or debugging information. This information may be useful in debugging or tuning a DICT server. All DICT servers MUST implement this command, although the text part of the response is not specified and may be omitted.