version 4.2.0
move toStdFunction() to pibase.h refactor PIParseHelper, now it much more abstract and useful fix PIIODevice::createFromFullPath() when whitespaces at start or end are presence PIStreamPacker add events for start and end packet receive PIClientServer::ClientBase add virtual methods for start and end packet receive. also one can enable diagnostics with enableDiagnostics() method PICout now call flush() on each end of output add PIString::entries(const PIString & str)
This commit is contained in:
@@ -29,6 +29,7 @@ PIClientServer::ClientBase::~ClientBase() {
|
||||
close();
|
||||
stopAndWait();
|
||||
if (own_tcp) piDeleteSafety(tcp);
|
||||
piDeleteSafety(diag);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,17 +61,38 @@ int PIClientServer::ClientBase::write(const void * d, const size_t s) {
|
||||
}
|
||||
|
||||
|
||||
void PIClientServer::ClientBase::enableDiagnostics() {
|
||||
if (diag) return;
|
||||
diag = new PIDiagnostics();
|
||||
}
|
||||
|
||||
|
||||
PIDiagnostics::State PIClientServer::ClientBase::diagnostics() const {
|
||||
if (!diag) return {};
|
||||
return diag->state();
|
||||
}
|
||||
|
||||
|
||||
int PIClientServer::ClientBase::receivePacketProgress() const {
|
||||
return stream.receivePacketProgress();
|
||||
}
|
||||
|
||||
|
||||
void PIClientServer::ClientBase::init() {
|
||||
if (!tcp) return;
|
||||
CONNECTL(&stream, sendRequest, [this](const PIByteArray & ba) {
|
||||
if (!can_write) return;
|
||||
tcp->send(ba);
|
||||
if (diag) diag->sended(ba.size_s());
|
||||
// piMSleep(1);
|
||||
});
|
||||
CONNECTL(&stream, packetReceiveEvent, [this](PIByteArray & ba) { readed(ba); });
|
||||
CONNECTL(&stream, startPacketReceive, [this](int size) { receivePacketStart(size); });
|
||||
CONNECTL(&stream, endPacketReceive, [this]() { receivePacketEnd(); });
|
||||
CONNECTL(tcp, threadedReadEvent, [this](const uchar * readed, ssize_t size) {
|
||||
if (!can_write) return;
|
||||
stream.received(readed, size);
|
||||
if (diag) diag->received(size);
|
||||
});
|
||||
CONNECTL(tcp, connected, [this]() {
|
||||
can_write = true;
|
||||
|
||||
Reference in New Issue
Block a user