An example of how to use the FramedTcpConnection class in a server
#include <iostream>
#include <cassert>
using namespace std;
class MyClass : public sigc::trackable
{
public:
MyClass(void)
{
mem_fun(*this, &MyClass::onClientConnected));
server->clientDisconnected.connect(
mem_fun(*this, &MyClass::onClientDisconnected));
cout << "Start AsyncFramedTcpClient_demo in another window to transfer "
"some frames to the server" << endl;
}
~MyClass(void)
{
delete server;
}
private:
{
con->
frameReceived.connect(mem_fun(*
this, &MyClass::onFrameReceived));
}
FramedTcpConnection::DisconnectReason reason)
{
}
{
cout << "Received a frame with " << buf.size() << " bytes of data\n";
if (buf.size() == 4)
{
std::string cmd(buf.begin(), buf.end());
cout << "Quitting!\n";
Application::app().quit();
}
else
{
uint8_t next = 0;
for (size_t i=0; i<buf.size(); ++i)
{
assert(buf[i] == next++);
}
}
}
};
int main(int argc, char **argv)
{
MyClass my_class;
}