OpenersNotesSection(Spacer1)Details

The urgent message handler function is called when WSTP receives an urgent message from the other end of the connection.

WSGetMessageHandler() returns ((NonWLLink[WSMessageHandlerObject, paclet:ref/c/WSMessageHandlerObject]))0 if link does not have an installed message handler function.

(NonWLLink[WSMessageHandlerObject, paclet:ref/c/WSMessageHandlerObject]) is a pointer to a function of the form void f((NonWLLink[WSLINK, paclet:ref/c/WSLINK]) link,int m1,int m2).

WSGetMessageHandler() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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 */ }
	}
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSSetMessageHandler(), paclet:ref/c/WSSetMessageHandler])  ▪  (NonWLLink[WSPutMessage(), paclet:ref/c/WSPutMessage])  ▪  (NonWLLink[WSGetMessage(), paclet:ref/c/WSGetMessage])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[Low-Level WSTP Operations, paclet:guide/LowLevelWSTPOperations])}})}})