[DEV] update nullptr in null (specific etk)
This commit is contained in:
parent
1617790e48
commit
79c20a74ea
@ -105,7 +105,7 @@ enet::Http::Http(enet::Tcp _connection, bool _isServer) :
|
|||||||
m_isServer(_isServer),
|
m_isServer(_isServer),
|
||||||
m_connection(etk::move(_connection)),
|
m_connection(etk::move(_connection)),
|
||||||
m_headerIsSend(false),
|
m_headerIsSend(false),
|
||||||
m_thread(nullptr),
|
m_thread(null),
|
||||||
m_threadRunning(false) {
|
m_threadRunning(false) {
|
||||||
//setSendHeaderProperties("User-Agent", "e-net (ewol network interface)");
|
//setSendHeaderProperties("User-Agent", "e-net (ewol network interface)");
|
||||||
/*
|
/*
|
||||||
@ -132,14 +132,14 @@ void enet::Http::threadCallback() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_observerRaw != nullptr) {
|
if (m_observerRaw != null) {
|
||||||
m_observerRaw(m_connection);
|
m_observerRaw(m_connection);
|
||||||
} else {
|
} else {
|
||||||
m_temporaryBuffer.resize(67000);
|
m_temporaryBuffer.resize(67000);
|
||||||
int32_t len = m_connection.read(&m_temporaryBuffer[0], m_temporaryBuffer.size());
|
int32_t len = m_connection.read(&m_temporaryBuffer[0], m_temporaryBuffer.size());
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
ENET_INFO("Call client with datas ...");
|
ENET_INFO("Call client with datas ...");
|
||||||
if (m_observer != nullptr) {
|
if (m_observer != null) {
|
||||||
m_observer(m_temporaryBuffer);
|
m_observer(m_temporaryBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ void enet::Http::start() {
|
|||||||
ENET_DEBUG("connect [START]");
|
ENET_DEBUG("connect [START]");
|
||||||
m_threadRunning = true;
|
m_threadRunning = true;
|
||||||
m_thread = ETK_NEW(ethread::Thread, [&](){ threadCallback();});
|
m_thread = ETK_NEW(ethread::Thread, [&](){ threadCallback();});
|
||||||
if (m_thread == nullptr) {
|
if (m_thread == null) {
|
||||||
m_threadRunning = false;
|
m_threadRunning = false;
|
||||||
ENET_ERROR("creating callback thread!");
|
ENET_ERROR("creating callback thread!");
|
||||||
return;
|
return;
|
||||||
@ -189,12 +189,12 @@ void enet::Http::stop(bool _inThreadStop){
|
|||||||
m_connection.unlink();
|
m_connection.unlink();
|
||||||
}
|
}
|
||||||
if (_inThreadStop == false) {
|
if (_inThreadStop == false) {
|
||||||
if (m_thread != nullptr) {
|
if (m_thread != null) {
|
||||||
ENET_DEBUG("wait join Thread ...");
|
ENET_DEBUG("wait join Thread ...");
|
||||||
m_thread->join();
|
m_thread->join();
|
||||||
ENET_DEBUG("wait join Thread (done)");
|
ENET_DEBUG("wait join Thread (done)");
|
||||||
ETK_DELETE(ethread::Thread, m_thread);
|
ETK_DELETE(ethread::Thread, m_thread);
|
||||||
m_thread = nullptr;
|
m_thread = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ENET_DEBUG("disconnect [STOP]");
|
ENET_DEBUG("disconnect [STOP]");
|
||||||
@ -547,11 +547,11 @@ void enet::Http::getHeader() {
|
|||||||
}
|
}
|
||||||
m_headerIsSend = true;
|
m_headerIsSend = true;
|
||||||
if (m_isServer == false) {
|
if (m_isServer == false) {
|
||||||
if (m_observerAnswer != nullptr) {
|
if (m_observerAnswer != null) {
|
||||||
m_observerAnswer(m_answerHeader);
|
m_observerAnswer(m_answerHeader);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_observerRequest != nullptr) {
|
if (m_observerRequest != null) {
|
||||||
m_observerRequest(m_requestHeader);
|
m_observerRequest(m_requestHeader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,8 +204,8 @@ int32_t enet::Tcp::write(const void* _data, int32_t _len) {
|
|||||||
ENET_ERROR("Can not write on unlink connection");
|
ENET_ERROR("Can not write on unlink connection");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (_data == nullptr) {
|
if (_data == null) {
|
||||||
ENET_ERROR("try write nullptr data on TCP socket");
|
ENET_ERROR("try write null data on TCP socket");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (_len <= 0) {
|
if (_len <= 0) {
|
||||||
|
@ -79,7 +79,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
hints.ai_protocol = IPPROTO_TCP;
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
|
||||||
// Resolve the server address and port
|
// Resolve the server address and port
|
||||||
struct addrinfo* result = nullptr;
|
struct addrinfo* result = null;
|
||||||
etk::String portValue = etk::toString(_port);
|
etk::String portValue = etk::toString(_port);
|
||||||
int iResult = getaddrinfo(_hostname.c_str(), portValue.c_str(), &hints, &result);
|
int iResult = getaddrinfo(_hostname.c_str(), portValue.c_str(), &hints, &result);
|
||||||
if (iResult != 0) {
|
if (iResult != 0) {
|
||||||
@ -89,7 +89,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
|
|
||||||
// Attempt to connect to an address until one succeeds
|
// Attempt to connect to an address until one succeeds
|
||||||
for(struct addrinfo* ptr=result;
|
for(struct addrinfo* ptr=result;
|
||||||
ptr != nullptr;
|
ptr != null;
|
||||||
ptr=ptr->ai_next) {
|
ptr=ptr->ai_next) {
|
||||||
ENET_DEBUG(" find one ...");
|
ENET_DEBUG(" find one ...");
|
||||||
// Create a SOCKET for connecting to server
|
// Create a SOCKET for connecting to server
|
||||||
@ -149,7 +149,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
}
|
}
|
||||||
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
||||||
struct sockaddr_in servAddr;
|
struct sockaddr_in servAddr;
|
||||||
struct hostent* server = nullptr;
|
struct hostent* server = null;
|
||||||
if ( _hostname.c_str()[0] >= '0'
|
if ( _hostname.c_str()[0] >= '0'
|
||||||
&& _hostname.c_str()[0] <= '9') {
|
&& _hostname.c_str()[0] <= '9') {
|
||||||
ENET_INFO("Calling gethostbyaddr with " << _hostname);
|
ENET_INFO("Calling gethostbyaddr with " << _hostname);
|
||||||
@ -167,7 +167,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
// TODO : This is deprecated use getaddrinfo like windows ...
|
// TODO : This is deprecated use getaddrinfo like windows ...
|
||||||
server = gethostbyname(_hostname.c_str());
|
server = gethostbyname(_hostname.c_str());
|
||||||
}
|
}
|
||||||
if (server == nullptr) {
|
if (server == null) {
|
||||||
ENET_ERROR("ERROR, no such host : " << _hostname);
|
ENET_ERROR("ERROR, no such host : " << _hostname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ void enet::TcpServer::setPort(uint16_t _port) {
|
|||||||
}
|
}
|
||||||
ENET_INFO("Start connection on " << m_host << ":" << m_port);
|
ENET_INFO("Start connection on " << m_host << ":" << m_port);
|
||||||
|
|
||||||
struct addrinfo *result = nullptr;
|
struct addrinfo *result = null;
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
ZeroMemory(&hints, sizeof(hints));
|
ZeroMemory(&hints, sizeof(hints));
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
@ -82,7 +82,7 @@ void enet::TcpServer::setPort(uint16_t _port) {
|
|||||||
|
|
||||||
// Resolve the server address and port
|
// Resolve the server address and port
|
||||||
etk::String portValue = etk::toString(m_port);
|
etk::String portValue = etk::toString(m_port);
|
||||||
int iResult = getaddrinfo(nullptr, portValue.c_str(), &hints, &result);
|
int iResult = getaddrinfo(null, portValue.c_str(), &hints, &result);
|
||||||
if (iResult != 0) {
|
if (iResult != 0) {
|
||||||
ENET_ERROR("getaddrinfo failed with error: " << iResult);
|
ENET_ERROR("getaddrinfo failed with error: " << iResult);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -29,22 +29,22 @@ namespace enet {
|
|||||||
|
|
||||||
enet::WebSocket::WebSocket() :
|
enet::WebSocket::WebSocket() :
|
||||||
m_connectionValidate(false),
|
m_connectionValidate(false),
|
||||||
m_interface(nullptr),
|
m_interface(null),
|
||||||
m_observer(nullptr),
|
m_observer(null),
|
||||||
m_observerUriCheck(nullptr) {
|
m_observerUriCheck(null) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enet::WebSocket::WebSocket(enet::Tcp _connection, bool _isServer) :
|
enet::WebSocket::WebSocket(enet::Tcp _connection, bool _isServer) :
|
||||||
m_connectionValidate(false),
|
m_connectionValidate(false),
|
||||||
m_interface(nullptr),
|
m_interface(null),
|
||||||
m_observer(nullptr),
|
m_observer(null),
|
||||||
m_observerUriCheck(nullptr) {
|
m_observerUriCheck(null) {
|
||||||
setInterface(etk::move(_connection), _isServer);
|
setInterface(etk::move(_connection), _isServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const etk::String& enet::WebSocket::getRemoteAddress() const {
|
const etk::String& enet::WebSocket::getRemoteAddress() const {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
static const etk::String tmpOut;
|
static const etk::String tmpOut;
|
||||||
return tmpOut;
|
return tmpOut;
|
||||||
}
|
}
|
||||||
@ -56,17 +56,17 @@ void enet::WebSocket::setInterface(enet::Tcp _connection, bool _isServer) {
|
|||||||
if (_isServer == true) {
|
if (_isServer == true) {
|
||||||
ememory::SharedPtr<enet::HttpServer> interface = ememory::makeShared<enet::HttpServer>(etk::move(_connection));
|
ememory::SharedPtr<enet::HttpServer> interface = ememory::makeShared<enet::HttpServer>(etk::move(_connection));
|
||||||
m_interface = interface;
|
m_interface = interface;
|
||||||
if (interface != nullptr) {
|
if (interface != null) {
|
||||||
interface->connectHeader(this, &enet::WebSocket::onReceiveRequest);
|
interface->connectHeader(this, &enet::WebSocket::onReceiveRequest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ememory::SharedPtr<enet::HttpClient> interface = ememory::makeShared<enet::HttpClient>(etk::move(_connection));
|
ememory::SharedPtr<enet::HttpClient> interface = ememory::makeShared<enet::HttpClient>(etk::move(_connection));
|
||||||
m_interface = interface;
|
m_interface = interface;
|
||||||
if (interface != nullptr) {
|
if (interface != null) {
|
||||||
interface->connectHeader(this, &enet::WebSocket::onReceiveAnswer);
|
interface->connectHeader(this, &enet::WebSocket::onReceiveAnswer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("can not create interface for the websocket");
|
ENET_ERROR("can not create interface for the websocket");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ void enet::WebSocket::setInterface(enet::Tcp _connection, bool _isServer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enet::WebSocket::~WebSocket() {
|
enet::WebSocket::~WebSocket() {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stop(true);
|
stop(true);
|
||||||
@ -96,7 +96,7 @@ static etk::String generateCheckKey(const etk::String& _key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::String>& _listProtocols) {
|
void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::String>& _listProtocols) {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::Stri
|
|||||||
req.setKey("Sec-WebSocket-Protocol", protocolList);
|
req.setKey("Sec-WebSocket-Protocol", protocolList);
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<enet::HttpClient> interface = ememory::dynamicPointerCast<enet::HttpClient>(m_interface);
|
ememory::SharedPtr<enet::HttpClient> interface = ememory::dynamicPointerCast<enet::HttpClient>(m_interface);
|
||||||
if (interface != nullptr) {
|
if (interface != null) {
|
||||||
interface->setHeader(req);
|
interface->setHeader(req);
|
||||||
int32_t timeout = 500000; // 5 second
|
int32_t timeout = 500000; // 5 second
|
||||||
while ( timeout>=0
|
while ( timeout>=0
|
||||||
@ -160,7 +160,7 @@ void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::Stri
|
|||||||
|
|
||||||
void enet::WebSocket::stop(bool _inThread) {
|
void enet::WebSocket::stop(bool _inThread) {
|
||||||
ENET_DEBUG("Stop interface ...");
|
ENET_DEBUG("Stop interface ...");
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -309,14 +309,14 @@ void enet::WebSocket::onReceiveData(enet::Tcp& _connection) {
|
|||||||
if ((opcode & 0x0F) == enet::websocket::OPCODE_FRAME_TEXT) {
|
if ((opcode & 0x0F) == enet::websocket::OPCODE_FRAME_TEXT) {
|
||||||
// Close the conection by remote:
|
// Close the conection by remote:
|
||||||
ENET_WARNING("Receive a Text(UTF-8) data " << m_buffer.size() << " Bytes");
|
ENET_WARNING("Receive a Text(UTF-8) data " << m_buffer.size() << " Bytes");
|
||||||
if (m_observer != nullptr) {
|
if (m_observer != null) {
|
||||||
m_observer(m_buffer, true);
|
m_observer(m_buffer, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((opcode & 0x0F) == enet::websocket::OPCODE_FRAME_BINARY) {
|
if ((opcode & 0x0F) == enet::websocket::OPCODE_FRAME_BINARY) {
|
||||||
// Close the conection by remote:
|
// Close the conection by remote:
|
||||||
if (m_observer != nullptr) {
|
if (m_observer != null) {
|
||||||
m_observer(m_buffer, false);
|
m_observer(m_buffer, false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -345,7 +345,7 @@ static etk::String removeStartAndStopSpace(const etk::String& _value) {
|
|||||||
|
|
||||||
void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
||||||
ememory::SharedPtr<enet::HttpServer> interface = ememory::dynamicPointerCast<enet::HttpServer>(m_interface);
|
ememory::SharedPtr<enet::HttpServer> interface = ememory::dynamicPointerCast<enet::HttpServer>(m_interface);
|
||||||
if (interface == nullptr) {
|
if (interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
|||||||
listProtocol[iii] = removeStartAndStopSpace(listProtocol[iii]);
|
listProtocol[iii] = removeStartAndStopSpace(listProtocol[iii]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_observerUriCheck != nullptr) {
|
if (m_observerUriCheck != null) {
|
||||||
etk::String ret = m_observerUriCheck(_data.getUri(), listProtocol);
|
etk::String ret = m_observerUriCheck(_data.getUri(), listProtocol);
|
||||||
if (ret == "OK") {
|
if (ret == "OK") {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
@ -427,7 +427,7 @@ void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enet::WebSocket::onReceiveAnswer(const enet::HttpAnswer& _data) {
|
void enet::WebSocket::onReceiveAnswer(const enet::HttpAnswer& _data) {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ int32_t enet::WebSocket::writeData(uint8_t* _data, int32_t _len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t enet::WebSocket::send() {
|
int32_t enet::WebSocket::send() {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -547,7 +547,7 @@ int32_t enet::WebSocket::write(const void* _data, int32_t _len, bool _isString,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enet::WebSocket::controlPing() {
|
void enet::WebSocket::controlPing() {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -561,7 +561,7 @@ void enet::WebSocket::controlPing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enet::WebSocket::controlPong() {
|
void enet::WebSocket::controlPong() {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -575,7 +575,7 @@ void enet::WebSocket::controlPong() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enet::WebSocket::controlClose() {
|
void enet::WebSocket::controlClose() {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
ENET_ERROR("Nullptr interface ...");
|
ENET_ERROR("Nullptr interface ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace enet {
|
|||||||
void start(const etk::String& _uri="", const etk::Vector<etk::String>& _listProtocols=etk::Vector<etk::String>());
|
void start(const etk::String& _uri="", const etk::Vector<etk::String>& _listProtocols=etk::Vector<etk::String>());
|
||||||
void stop(bool _inThread=false);
|
void stop(bool _inThread=false);
|
||||||
bool isAlive() const {
|
bool isAlive() const {
|
||||||
if (m_interface == nullptr) {
|
if (m_interface == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_interface->isAlive();
|
return m_interface->isAlive();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user