3.1.3 Initialization

A NetDDE conversation is first established between a client and server machine as follows (see [MSDN-NETDDE]  and [MSDN-DDE] for further details):

  • The NetDDE server machine creates a static network DDE share using NddeShareAdd method. The DDE share MUST be named "CHAT$" and MUST have the static topic name of "Chat".

  • The NetDDE client machine initiates the DDE conversation using DdeConnect method. The DdeConnect service name MUST be of the form "\\computername\NDDE$", where computername is the NetBIOS name of the server machine. The DdeConnect topic name MUST be "CHAT$".

  • The NetDDE server machine MUST acquire the client name using DdeQueryString method during the XTYP_ADVSTART callback. This name is stored as Session.ClientName.

  • Chat message data as defined in section 2.3 is encapsulated in NetDDE data blocks for transfer between chat participants.

Storing message in DDE data block: The participant uses DdeCreateDataHandle method to create a data block of the correct size as specified by section 2.3. The string specifying the data item MUST be "ChatText". The clipboard format MUST be the result from RegisterClipboardFormat ("Chat Data"). The participant copies the CHATDATA message to the DDE data block using DdeAddData method.

Extracting message from DDE data block: The participant uses DdeGetData method to retrieve the first two bytes of data from the DDE data block, which it interprets as ChatMessageType. Based on this, the participant determines the message type and the remaining message size as specified by section 2.3 and reads the data with subsequent DdeGetData method calls.

Message sent from client to server: The client stores the message in a DDE data block. The DDE data is sent using DdeClientTransaction with XTYP_POKE as the transaction type. The server receives this information via an XTYP_POKE transaction processed by its DdeCallback function, and extracts the message from the DDE data block.

Message sent from server to client: The server MUST use DdePostAdvise method to inform the client that data is available. The DDE topic name MUST be "Chat" and the DDE item name MUST be Session.ClientName. The client will present the server with an XTYP_ADVREQ transaction. The server stores the message and returns the resulting data block to complete the XTYP_ADVREQ transaction. The client receives an XTYP_ADVDATA transaction in its DdeCallback function, and extracts the message from the DDE data block.

After initialization of the NetDDE conversation, the participant SHOULD send a CHATDATA_PROTOCOL message. If the participant supports Unicode, the participant MUST send a CHATDATA_UNICODE message.