threadedRead now const uchar *
pipacketextractor Header mode now more flexible fix splitTime mode more refactoring add virtual override to functions remove piforeach replace 0 to nullptr iterate over pimap via iterators replace CONNECTU to CONNECT# with compile time check
This commit is contained in:
@@ -6,12 +6,12 @@ public:
|
||||
Client(PIEthernet * eth_) {
|
||||
eth = eth_;
|
||||
eth->startThreadedRead();
|
||||
CONNECTU(eth, threadedReadEvent, this, readed);
|
||||
CONNECTU(eth, disconnected, this, disconnected);
|
||||
CONNECT2(void, const uchar *, int, eth, threadedReadEvent, this, readed);
|
||||
CONNECT1(void, bool, eth, disconnected, this, disconnected);
|
||||
piCoutObj << uint(eth) << "client connected";
|
||||
}
|
||||
~Client() {}
|
||||
EVENT_HANDLER2(void, readed, uchar * , data, int, size) {
|
||||
EVENT_HANDLER2(void, readed, const uchar *, data, int, size) {
|
||||
PIByteArray ba(data, size);
|
||||
piCoutObj << uint(eth) << "readed" << size << "bytes" << Hex << ba;
|
||||
eth->write(ba);
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
Server(int port) {
|
||||
eth = new PIEthernet(PIEthernet::TCP_Server);
|
||||
eth->setParameter(PIEthernet::ReuseAddress);
|
||||
CONNECTU(eth, newConnection, this, newConnection);
|
||||
CONNECT1(void, PIEthernet *, eth, newConnection, this, newConnection);
|
||||
PIString path = "0.0.0.0:" + PIString::fromNumber(port);
|
||||
eth->listen(path, true);
|
||||
piCoutObj << uint(eth) << "server started" << path;
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
EVENT_HANDLER1(void, newConnection, PIEthernet * , cl) {
|
||||
piCoutObj << uint(eth) << "add client";
|
||||
Client * client = new Client(cl);
|
||||
CONNECTU(client, disconnect, this, disconnect);
|
||||
CONNECT1(void, Client *, client, disconnect, this, disconnect);
|
||||
clients.push_back(client);
|
||||
}
|
||||
EVENT_HANDLER1(void, disconnect, Client *, client) {
|
||||
|
||||
Reference in New Issue
Block a user