This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Httpd.h Source File

Httpd.h

00001 #pragma once
00002 ////////////////////////////////////////////////////////////////////////////////
00003 // Httpd.h
00004 ////////////////////////////////////////////////////////////////////////////////
00005 
00006 #include "NyLPC_net.h"
00007 
00008 namespace MiMic
00009 {
00010     class HttpdConnection;
00011     class Httpd
00012     {
00013     private:
00014         struct Httpd2{
00015             NyLPC_TcHttpd_t super;
00016             Httpd* _parent;
00017         }_inst;
00018         static void onRequestHandler(NyLPC_TcHttpdConnection_t* i_connection);
00019         static int taskHandler(void* i_param);
00020     public:
00021         /**
00022          * This function create an instance with service port number.
00023          * @param i_port_number
00024          * HTTP service port number.
00025          */
00026         Httpd(int i_port_number);
00027         virtual ~Httpd();
00028         /**
00029          * This function starts HTTP listen loop on current task.
00030          * The function never return.
00031          * Must not use after called loopTask function.
00032          */
00033         void loop();
00034         /**
00035          * This function starts HTTP listen loop on a new task.
00036          */
00037         void loopTask();
00038         /**
00039          * This function gets a lock.
00040          * This function is used for exclusive process in request handler or other task.
00041          */
00042         void lock();
00043         /**
00044          * This function releases a lock.
00045          */
00046         void unlock();
00047         /**
00048          * The handler function for HTTP request.
00049          * Must implement the function in extended class.
00050          * This is called when HTTPD received HTTP request.
00051          * The function may be call in multiple.
00052          * @param i_connection
00053          * HTTP connection object that contain "prefetched" HTTP stream.
00054          */
00055         virtual void onRequest(HttpdConnection& i_connection)=0;
00056     public:
00057         const static int SIZE_OF_HTTP_BUF=512;
00058         /**
00059          * This buffer is a shared buffer for HTTPD modules.
00060          * It will be use for temporary buffer or work memory. 
00061          * Must lock before using.
00062          */
00063         static char _shared_buf[SIZE_OF_HTTP_BUF];
00064     };
00065 }