本文整理汇总了C++中TcpConnection::setListener方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::setListener方法的具体用法?C++ TcpConnection::setListener怎么用?C++ TcpConnection::setListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnection
的用法示例。
在下文中一共展示了TcpConnection::setListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
void runTest() {
m_strategy = new OpenConnectionStrategy(this);
m_client_listener = new ClientTcpListener(this);
m_server_listener = new ServerTcpListener(this);
m_evmanager = new EventManager();
m_client = new TcpConnection(IpAddress("127.0.0.1", 9999));
m_listener = new TcpListener();
m_listener->listen(9999);
m_listener->setListener(this);
m_client->setEventManager(m_evmanager);
m_client->setListener(m_client_listener);
m_client->open();
m_evmanager->registerClient(m_listener);
m_evmanager->registerClient(m_client);
m_evmanager->execute();
delete m_strategy;
delete m_client_listener;
delete m_server_listener;
delete m_client;
delete m_server;
delete m_listener;
delete m_evmanager;
}
示例2: onAccepted
virtual void onAccepted(TcpSocket *socket) {
m_server = new TcpConnection(socket);
m_server->setEventManager(m_evmanager);
m_server->setListener(m_server_listener);
m_evmanager->registerClient(m_server);
}