mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-16 07:23:07 +01:00
externalize socket connection
This commit is contained in:
36
lib/socketserver/GwSocketConnection.h
Normal file
36
lib/socketserver/GwSocketConnection.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <lwip/sockets.h>
|
||||
#include "GwBuffer.h"
|
||||
class GwSocketConnection
|
||||
{
|
||||
public:
|
||||
int fd=-1;
|
||||
int overflows;
|
||||
String remoteIpAddress;
|
||||
|
||||
private:
|
||||
unsigned long lastWrite = 0;
|
||||
unsigned long writeTimeout = 10000;
|
||||
bool pendingWrite = false;
|
||||
bool writeError = false;
|
||||
bool allowRead;
|
||||
GwBuffer *buffer = NULL;
|
||||
GwBuffer *readBuffer = NULL;
|
||||
GwLog *logger;
|
||||
|
||||
public:
|
||||
static IPAddress remoteIP(int fd);
|
||||
GwSocketConnection(GwLog *logger, int id, bool allowRead = false);
|
||||
void setClient(int fd);
|
||||
bool hasClient();
|
||||
void stop();
|
||||
~GwSocketConnection();
|
||||
bool connected();
|
||||
bool enqueue(uint8_t *data, size_t len);
|
||||
bool hasData();
|
||||
bool handleError(int res, bool errorIf0 = true);
|
||||
GwBuffer::WriteStatus write();
|
||||
bool read();
|
||||
bool messagesFromBuffer(GwMessageFetcher *writer);
|
||||
};
|
||||
Reference in New Issue
Block a user