コード例 #1
0
    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
0
 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);
 }