WSMessageHandlerObject
This feature is not supported on the Wolfram Cloud.


is a WSTP type that describes a function pointer to a function taking three arguments: an WSLINK, an int, and an int, and returning a void that implements an urgent message handler.

DetailsDetails

  • The urgent message handler function is called when WSTP receives an urgent message from the other end of the connection.
  • WSMessageHandlerObject is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"


/* handle three common WSTP urgent messages */

void f(MLINK lp, int msg, int arg)
{
    if(msg == WSInterruptMessage)
        { /* generate an interrupt menu */ }
    else if(msg == WSAbortMessage)
        { /* abort the current operation */ }
    else if(msg == WSTerminateMessage)
        { /* shutdown the program */ }

    /* ... */
}


int main(int argc, char **argv)
{
    MLENV env;
    MLINK link;
    int error;

    env = WSInitialize((WSEnvironmentParameter)0);
    if(env == (MLENV)0)
        { /* unable to initialize WSTP environment */ }

    link = WSOpenArgcArgv(env, argc, argv, &error);
    if(link == (MLINK)0 || error != MLEOK)
        { /* unable to create link */ }

    if(! WSSetMessageHandler(link, (WSMessageHandlerObject)f)
        { /* unable to install message handler for link */ }

    /* ... */

    WSClose(link);
    WSDeinitialize(env);

    return 0;
}