httpOnConnectionClose()

The function starts the specified callBack function when the HTTP connection is closed.

Synopsis

int httpOnConnectionClose(string | function_ptr callBackFunc);

Parameter

Parameter Description
callBack The callBack function that is started when the connection is closed. Given either by name or with a function pointer.

Return value

The function returns 0 if it was successfully executed and -1 in case of errors.

Error

  • An httpServer was not created

  • Missing parameter in the function

  • The callBack function does not exist

  • Another callBack function was registered for "onConnectionClose"

Description

The function starts the specified callBack function with the arguments clientIP and idx when the HTTP connection to the client with Index idx is closed.

Example

#uses "CtrlHTTP"



main()



{



  httpServer(false); /* Installs the HTTP server */



  httpConnect("example", "/firstExample"); /* Registers the CTRL function  "example" as a Web resource */



  httpOnConnectionClose("callBf");  /*Starts the CallBack function "callBf" when the HTTP connection to the client with Index idx is closed.    */



}



string example()/* The example  returns an HTML page: */



{



  return "<html><head><title>First example</title></head>"



 "<body>This is my first example</body></html>";



}



string callBf(string clientIp, int idx)



{



  DebugN("Closed the HTTP connection");



}

Assignment

CTRL PlugIn

Availability

CTRL, UI