WSGetMessageHandler()

WSMessageHandlerObject WSGetMessageHandler(WSLINK link)

returns the message handler function installed for the WSLINK object link.

Details

  • The urgent message handler function is called when WSTP receives an urgent message from the other end of the connection.
  • WSGetMessageHandler() returns (WSMessageHandlerObject)0 if link does not have an installed message handler function.
  • WSMessageHandlerObject is a pointer to a function of the form void f(WSLINK link,int m1,int m2).
  • WSGetMessageHandler() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* a function to read WSTP urgent messages */

void AppMessageHandler(WSLINK link, int m1, int m2)
{
    /* ... */
}


/* check that a link uses AppMessageHandler for urgent messages */

void check_the_message_handler(WSLINK link)
{
    WSMessageHandlerObject handler;

    handler = WSGetMessageHandler(link);
    if(handler != (WSMessageHandlerObject)AppMessageHandler)
    {
        if(! WSSetMessageHandler(link, (WSMessageHandlerObject)AppMessageHandler))
            { /* unable to set AppMessageHandler as the handler for
             link */ }
    }
}

See Also

WSSetMessageHandler()  WSPutMessage()  WSGetMessage()

Tutorials