Jun Furutani / libMiMic

Fork of libMiMic by Ryo Iizuka

Committer:
nyatla
Date:
Thu Jul 11 03:52:33 2013 +0000
Revision:
45:63d6aa80e26d
Parent:
19:33b9ba0859ee
Child:
46:61edfd4b16ee
add Httpd::loopTask function;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 3:0a94993be1f6 1 #include "Httpd.h"
nyatla 3:0a94993be1f6 2 #include "HttpdConnection.h"
nyatla 3:0a94993be1f6 3 namespace MiMic
nyatla 3:0a94993be1f6 4 {
nyatla 19:33b9ba0859ee 5 char Httpd::_shared_buf[SIZE_OF_HTTP_BUF];
nyatla 19:33b9ba0859ee 6
nyatla 3:0a94993be1f6 7 void Httpd::onRequestHandler(NyLPC_TcHttpdConnection_t* i_connection)
nyatla 3:0a94993be1f6 8 {
nyatla 3:0a94993be1f6 9 HttpdConnection c(i_connection);
nyatla 3:0a94993be1f6 10 ((struct Httpd2*)(i_connection->_parent_httpd))->_parent->onRequest(c);
nyatla 3:0a94993be1f6 11 }
nyatla 3:0a94993be1f6 12 Httpd::Httpd(int i_port_number)
nyatla 3:0a94993be1f6 13 {
nyatla 3:0a94993be1f6 14 NyLPC_cHttpd_initialize((NyLPC_TcHttpd_t*)(&this->_inst),(NyLPC_TUInt16)i_port_number);
nyatla 3:0a94993be1f6 15 this->_inst._parent=this;
nyatla 3:0a94993be1f6 16 this->_inst.super.function.onRequest=onRequestHandler;
nyatla 3:0a94993be1f6 17 }
nyatla 3:0a94993be1f6 18 Httpd::~Httpd()
nyatla 3:0a94993be1f6 19 {
nyatla 3:0a94993be1f6 20 NyLPC_cHttpd_finalize((NyLPC_TcHttpd_t*)(&this->_inst));
nyatla 3:0a94993be1f6 21 }
nyatla 3:0a94993be1f6 22 void Httpd::loop()
nyatla 3:0a94993be1f6 23 {
nyatla 3:0a94993be1f6 24 NyLPC_cHttpd_loop((NyLPC_TcHttpd_t*)(&this->_inst));
nyatla 45:63d6aa80e26d 25 }
nyatla 19:33b9ba0859ee 26 void Httpd::lock()
nyatla 19:33b9ba0859ee 27 {
nyatla 19:33b9ba0859ee 28 NyLPC_cHttpd_lock((NyLPC_TcHttpd_t*)(&this->_inst));
nyatla 19:33b9ba0859ee 29 }
nyatla 19:33b9ba0859ee 30 void Httpd::unlock()
nyatla 19:33b9ba0859ee 31 {
nyatla 19:33b9ba0859ee 32 NyLPC_cHttpd_unlock((NyLPC_TcHttpd_t*)(&this->_inst));
nyatla 19:33b9ba0859ee 33 }
nyatla 45:63d6aa80e26d 34 void Httpd::loopTask()
nyatla 45:63d6aa80e26d 35 {
nyatla 45:63d6aa80e26d 36 NyLPC_TcThread_t* th=(NyLPC_TcThread_t*)malloc(sizeof(NyLPC_TcThread_t));
nyatla 45:63d6aa80e26d 37 NyLPC_cThread_initialize(th,256,NyLPC_TcThread_PRIORITY_IDLE);
nyatla 45:63d6aa80e26d 38 NyLPC_cThread_start(th,Httpd::taskHandler,&(this->_inst));
nyatla 45:63d6aa80e26d 39 }
nyatla 45:63d6aa80e26d 40 int Httpd::taskHandler(void* i_param)
nyatla 45:63d6aa80e26d 41 {
nyatla 45:63d6aa80e26d 42 NyLPC_cHttpd_loop((NyLPC_TcHttpd_t*)i_param);
nyatla 45:63d6aa80e26d 43 }
nyatla 19:33b9ba0859ee 44
nyatla 3:0a94993be1f6 45 }