2. Build the default database by sending the addItem:topic:value:format: message to the DdeServerManager for each item that you want to make available to DDE clients.
3. Send the updateItem:topic:value:format: message to the DdeServerManager each time the value of the item changes.
4. By using default processing, the DdeServerManager (along with the default database) handles all connection requests from DDE clients as well as requests for hotlinks, warmlinks, coldlinks, and data.By default, data sent from any DDE client to your DdeServerManager (a poke, in DDE terminology) is rejected. Requests from the client for the server to run commands are also rejected. However, both of these callbacks can be hooked, enabling the application to service these requests.
• The current time in a String format
• The current date in a String formatFirst, create a class called DdeTimeServer that is a subclass of Object. Give it the two instance variables described in Table 43.
Object subclass: #DdeTimeServerNow create a class method new to create a new server. Send the initialize method to the new object in order to set it up.Before executing the new class method, you need to create the initialize method. In the initialize method, first create the DdeServerManager and name it Timer. Next, build the default database.With the default database setup you do not have to hook into any of the callbacks provided by the DdeServerManager. All you need to do is to update the items when the timer goes off. Notice that for the format of 'String,' you pass a Smalltalk String for the data. When the format is 'Smalltalk Object,' you use the IBM Smalltalk Swapper to convert the Smalltalk object into a ByteArray. The method flatten to perform this function is specified in Converting Smalltalk objects to a ByteArray and back.At the end of initialization the timer is turned on by sending the timerOn: message, which in turn sends the timerSet message. The timer uses the Common Widgets timer functionality so that when the timer goes off, the message timerProc: is sent to the application.timerOn: aBooleanNow all initialization has been completed. The main work of the server is now in the method that is run whenever the timer goes off. When the timer goes off and the timerProc: method is run, all the items in the default database are updated. As the items are updated, the DdeServerManager looks for any hot- or warmlinks to the data and updates the clients that are linked to those items.timerProc: clientDataThe final method that you need to implement is the free method. This method stops the timer and frees up the DdeServerManager.
|