Skip to content

Commit 6967475

Browse files
committed
FIX: implemented recent interface changes on esp32's networking impl
1 parent 88bedfb commit 6967475

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/tiny_websockets/network/esp32/esp32_tcp.hpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,28 @@ namespace websockets { namespace network {
1717
client.setNoDelay(true);
1818
}
1919

20-
bool connect(WSString host, int port) {
20+
bool connect(const WSString& host, int port) {
2121
auto didConnect = client.connect(host.c_str(), port);
2222
client.setNoDelay(true);
2323
return didConnect;
2424
}
2525

26-
bool poll() {
26+
bool poll() override {
2727
return client.available();
2828
}
2929

3030
bool available() override {
3131
return static_cast<bool>(client);
3232
}
3333

34-
void send(WSString data) override {
35-
client.write(reinterpret_cast<uint8_t*>(const_cast<char*>(data.c_str())), data.size());
34+
void send(const WSString& data) override {
35+
client.write(reinterpret_cast<const uint8_t*>(data.c_str()), data.size());
36+
}
37+
void send(const WSString&& data) override {
38+
client.write(reinterpret_cast<const uint8_t*>(data.c_str()), data.size());
3639
}
3740

38-
void send(uint8_t* data, uint32_t len) override {
41+
void send(const uint8_t* data, const uint32_t len) override {
3942
client.write(data, len);
4043
}
4144

@@ -51,7 +54,7 @@ namespace websockets { namespace network {
5154
return line;
5255
}
5356

54-
void read(uint8_t* buffer, uint32_t len) override {
57+
void read(uint8_t* buffer, const uint32_t len) override {
5558
client.read(buffer, len);
5659
}
5760

@@ -62,6 +65,12 @@ namespace websockets { namespace network {
6265
virtual ~Esp32TcpClient() {
6366
close();
6467
}
68+
69+
protected:
70+
int getSocket() const override {
71+
return client.fd();
72+
}
73+
6574
private:
6675
WiFiClient client;
6776
};
@@ -73,7 +82,7 @@ namespace websockets { namespace network {
7382
return server.hasClient();
7483
}
7584

76-
bool listen(uint16_t port) override {
85+
bool listen(const uint16_t port) override {
7786
server = WiFiServer(port);
7887
server.begin(port);
7988
return available();
@@ -100,6 +109,12 @@ namespace websockets { namespace network {
100109
virtual ~Esp32TcpServer() {
101110
if(available()) close();
102111
}
112+
113+
protected:
114+
int getSocket() const override {
115+
return -1; // Not Implemented
116+
}
117+
103118
private:
104119
WiFiServer server;
105120
};

0 commit comments

Comments
 (0)