Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following example shows a function that could be registered in lmxserverconf.c:

Code Block
languagecpp
/* The function parameters should be overwritten by the response back to the client. */

...


void LMX_CALLBACK ServerFunc(char *szMessage)

...


{

...


  char *szTest = "this is a simple response";

...


  LmxLogprintf("server function called: %s", szMessage);

...


  
  /* Use the client message in some way ...*/

...


  ...

...


  ...

...


  ...

...


  /* Prepare response */

...


  strcpy(szMessage, szTest);

...


}

The client can then invoke the function given above as follows:

Code Block
languagecpp
char szMyMessage[LMX_MAX_LONG_STRING_LENGTH+1];

...


char *szString = "This is my simple query";

...


int nLength;

...


LMX_STATUS LmxStat;

...


/* Specify a message to send (here we use a zero-terminated string, but any data could be used */

...


strcpy(szMyMessage, szString);

...


LmxStat = LMX_ServerFunction(handle, "f1", szMyMessage);

...


/* Now the query has been replaced with a response */

...


/* Print out the response since we know the server sent us a string */

...


printf("%s\n", szMyMessage);