mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-13 05:53:06 +01:00
intermediate: introduce an abstract channel
This commit is contained in:
@@ -133,25 +133,23 @@ void GwSocketServer::loop(bool handleRead, bool handleWrite)
|
||||
}
|
||||
}
|
||||
|
||||
bool GwSocketServer::readMessages(GwMessageFetcher *writer)
|
||||
void GwSocketServer::readMessages(GwMessageFetcher *writer)
|
||||
{
|
||||
if (!allowReceive || !clients)
|
||||
return false;
|
||||
bool hasMessages = false;
|
||||
return;
|
||||
for (int i = 0; i < maxClients; i++)
|
||||
{
|
||||
writer->id = minId + i;
|
||||
if (!clients[i]->hasClient())
|
||||
continue;
|
||||
if (clients[i]->messagesFromBuffer(writer))
|
||||
hasMessages = true;
|
||||
clients[i]->messagesFromBuffer(writer);
|
||||
}
|
||||
return hasMessages;
|
||||
return;
|
||||
}
|
||||
void GwSocketServer::sendToClients(const char *buf, int source)
|
||||
size_t GwSocketServer::sendToClients(const char *buf, int source,bool partial)
|
||||
{
|
||||
if (!clients)
|
||||
return;
|
||||
return 0;
|
||||
int len = strlen(buf);
|
||||
int sourceIndex = source - minId;
|
||||
for (int i = 0; i < maxClients; i++)
|
||||
@@ -166,6 +164,7 @@ void GwSocketServer::sendToClients(const char *buf, int source)
|
||||
client->enqueue((uint8_t *)buf, len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int GwSocketServer::numClients()
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
#include "GWConfig.h"
|
||||
#include "GwLog.h"
|
||||
#include "GwBuffer.h"
|
||||
#include "GwChannelInterface.h"
|
||||
#include <memory>
|
||||
|
||||
class GwSocketConnection;
|
||||
class GwSocketServer{
|
||||
class GwSocketServer: public GwChannelInterface{
|
||||
private:
|
||||
const GwConfigHandler *config;
|
||||
GwLog *logger;
|
||||
@@ -22,9 +23,9 @@ class GwSocketServer{
|
||||
GwSocketServer(const GwConfigHandler *config,GwLog *logger,int minId);
|
||||
~GwSocketServer();
|
||||
void begin();
|
||||
void loop(bool handleRead=true,bool handleWrite=true);
|
||||
void sendToClients(const char *buf,int sourceId);
|
||||
virtual void loop(bool handleRead=true,bool handleWrite=true);
|
||||
virtual size_t sendToClients(const char *buf,int sourceId, bool partialWrite=false);
|
||||
int numClients();
|
||||
bool readMessages(GwMessageFetcher *writer);
|
||||
virtual void readMessages(GwMessageFetcher *writer);
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user