37 lines
772 B
C++
37 lines
772 B
C++
#include "dispatcherclient.h"
|
|
|
|
|
|
DispatcherClient::DispatcherClient(PIEthernet * eth_) {
|
|
eth = eth_;
|
|
CONNECTU(&disconnect_tm, tickEvent, eth, close);
|
|
eth->startThreadedRead();
|
|
CONNECTU(eth, threadedReadEvent, this, readed);
|
|
CONNECTU(eth, disconnected, this, disconnected);
|
|
piCoutObj << "client connected" << eth->sendAddress();
|
|
disconnect_tm.start(10000);
|
|
}
|
|
|
|
|
|
DispatcherClient::~DispatcherClient() {
|
|
// delete eth;
|
|
}
|
|
|
|
|
|
PIString DispatcherClient::address() {
|
|
return eth->path();
|
|
}
|
|
|
|
|
|
void DispatcherClient::disconnected(bool withError) {
|
|
piCoutObj << "client disconnected" << eth->sendAddress();
|
|
disconnectEvent(this);
|
|
}
|
|
|
|
|
|
void DispatcherClient::readed(uchar *data, int size) {
|
|
PIByteArray ba(data, size);
|
|
piCoutObj << "readed" << ba.toHex();
|
|
eth->write(ba);
|
|
}
|
|
|