1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

add some time measurements

This commit is contained in:
wellenvogel
2021-12-05 12:38:24 +01:00
parent 5b2c6a3a9a
commit c5b6de32a9
3 changed files with 127 additions and 11 deletions

View File

@@ -166,7 +166,7 @@ void GwSocketServer::begin(){
MDNS.addService("_nmea-0183","_tcp",config->getInt(config->serverPort));
}
void GwSocketServer::loop(bool handleRead)
void GwSocketServer::loop(bool handleRead,bool handleWrite)
{
if (! clients) return;
WiFiClient client = server->available(); // listen for incoming clients
@@ -193,17 +193,20 @@ void GwSocketServer::loop(bool handleRead)
client.stop();
}
}
//sending
for (int i = 0; i < maxClients; i++)
if (handleWrite)
{
gwClientPtr client = clients[i];
if (!client->hasClient())
continue;
GwBuffer::WriteStatus rt = client->write();
if (rt == GwBuffer::ERROR)
//sending
for (int i = 0; i < maxClients; i++)
{
LOG_DEBUG(GwLog::ERROR, "write error on %s, closing", client->remoteIp.c_str());
client->client->stop();
gwClientPtr client = clients[i];
if (!client->hasClient())
continue;
GwBuffer::WriteStatus rt = client->write();
if (rt == GwBuffer::ERROR)
{
LOG_DEBUG(GwLog::ERROR, "write error on %s, closing", client->remoteIp.c_str());
client->client->stop();
}
}
}
for (int i = 0; i < maxClients; i++)

View File

@@ -22,7 +22,7 @@ class GwSocketServer{
GwSocketServer(const GwConfigHandler *config,GwLog *logger,int minId);
~GwSocketServer();
void begin();
void loop(bool handleRead=true);
void loop(bool handleRead=true,bool handleWrite=true);
void sendToClients(const char *buf,int sourceId);
int numClients();
bool readMessages(GwMessageFetcher *writer);