42aefe8ed8
Started porting iosender to C++
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <thread>
|
|
#include "comms.h"
|
|
|
|
namespace iosender {
|
|
|
|
class TelnetStream : public StreamComms {
|
|
public:
|
|
|
|
TelnetStream(std::string host, DataReceivedHandler* dataHandler = nullptr, ByteReceivedHandler *byteHandler = nullptr);
|
|
~TelnetStream() override;
|
|
|
|
bool IsOpen() override;
|
|
int OutCount() override;
|
|
std::string Reply() override;
|
|
Comms::StreamType StreamType() override;
|
|
bool EventMode() override;
|
|
void EventMode(bool mode) override;
|
|
void Close() override;
|
|
int ReadByte() override;
|
|
void WriteByte(uint8_t data) override;
|
|
void WriteBytes(uint8_t *bytes, int len) override;
|
|
void WriteString(std::string data) override;
|
|
void WriteCommand(std::string command) override;
|
|
std::string GetReply(std::string command) override;
|
|
void AwaitAck() override;
|
|
void AwaitAck(std::string command) override;
|
|
void AwaitResponse(std::string command) override;
|
|
void AwaitResponse() override;
|
|
void PurgeQueue() override;
|
|
|
|
|
|
private:
|
|
volatile bool shouldQuit = false;
|
|
void readWorker();
|
|
|
|
std::string reply;
|
|
int fd;
|
|
bool isConnected;
|
|
bool eventMode = true;
|
|
std::thread workerThread;
|
|
};
|
|
|
|
|
|
} |