Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
Diff: mbed/mod/ModWebSocket.cpp
- Revision:
- 81:e5e4f2264d24
- Parent:
- 73:8c7dd6fd462e
diff -r b94c3dec9848 -r e5e4f2264d24 mbed/mod/ModWebSocket.cpp
--- a/mbed/mod/ModWebSocket.cpp Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/mod/ModWebSocket.cpp Tue Jun 24 14:34:39 2014 +0000
@@ -20,6 +20,10 @@
this->_mod=NULL;
}
}
+ bool ModWebSocket::isStarted(){
+ return this->_mod!=NULL;
+ }
+
void ModWebSocket::setParam(const char* i_path)
{
ModBaseClass::setParam(i_path);
@@ -27,10 +31,14 @@
bool ModWebSocket::execute(HttpdConnection& i_connection)
{
+ i_connection.lockHttpd();
if(this->_mod!=NULL){
+ i_connection.unlockHttpd();
return false;
}
this->_mod=(NyLPC_TcModWebSocket_t*)malloc(sizeof(NyLPC_TcModWebSocket_t));
+ i_connection.unlockHttpd();
+
if(this->_mod==NULL){
return false;
}
@@ -43,7 +51,9 @@
}
NyLPC_cModWebSocket_finalize(this->_mod);
free(this->_mod);
+ i_connection.lockHttpd();
this->_mod=NULL;
+ i_connection.unlockHttpd();
return false;
}
bool ModWebSocket::write(const void* i_tx_buf,int i_tx_size)
@@ -77,6 +87,9 @@
}
bool ModWebSocket::canRead()
{
+ if(this->_mod==NULL){
+ return false;
+ }
return NyLPC_cModWebSocket_canRead(this->_mod)?true:false;
}
