|
•
|
Hook the necessary DdeServerManager callbacks ( DdeNcoldlinkCallback, DdeNhotlinkCallback, DdeNinitiateCallback, DdeNrequestCallback, DdeNwarmlinkCallback).
|
If you follow this procedure, the DdeServerManager will
not handle
any requests from DDE clients. Methods must be written and callbacks hooked in order to provide service. This technique of providing DDE server services takes more work but allows for more flexibility.
Third, create the initialize method. In the
initialize method you first create the
DdeServerManager and name it
Timer. Next you hook up to the callbacks and turn the timer on.
Next, create the callback methods that implement the behavior of this server. First you implement the callback for the DdeNinitiateCallback. The
initiate:clientData:callData: method checks that the application name and the topic to which the client is attempting to connect match what the server is looking for. If they do match, then the application sends the
notifyClientOfSupportFor: message to the
DdeServer and sets the return value of the
DdeCallbackData object to
true. To reject the connect attempt, set the return value of the
DdeCallbackData object to
false. Notice that you are not attempting to handle an empty string for the application name or the topic name. The code should be embellished to handle this possible situation.
The code that follows is for the DdeNhotlinkCallback method. The method checks the item name and the format. It sets the
DdeCallbackData object to
true if the item is supported and
false otherwise.
The next callback you implement is DdeNrequestCallback. This callback is run when the client requests data from the server. As in previous examples, you check whether the item and the format are what you are looking for, then send the data to the client by sending the message
sendItem:value:format: to the
DdeServer that was passed to the callback method. The return value of the
DdeCallbackData object should be set to
true if the data is sent to the client and
false if the data is not sent to the client.
After the updateItem:topic:value:format: message is completed, the data passed as the value parameter is lost. The
DdeServerManager does not keep a copy of this data. When the default database is used, the data is kept so that when a client requests the data the
DdeServerManager can give the data back without intervention from the application. The implication is that if a server has many items or lots of data, it might not be able to use default processing and the default database because of memory restrictions. In that case the server has to hook the callbacks and process the events itself.
The message: method that has been used throughout the example follows:
Copyright 2005, 2020 Instantiations, Inc. All rights reserved.