从零构建自己的远控•客户端设计面向对象(13)

#include <stdio.h>
#include <windows.h>

class CManager;


class CClientSocket
{
public:
    void setManagerCallBack(CManager* pManager);
    CManager* m_pManager;
    bool Connect();//每一个模块单独创建连接

};

void CClientSocket::setManagerCallBack(CManager* pManager)
{
    m_pManager = pManager;
}

class CManager
{
public:
    CManager(CClientSocket* pClient);
    
    CClientSocket* m_pClient;
    virtual void OnReceive();//不同dlg 进行虚写
};
CManager::CManager(CClientSocket* pClient)
{
    m_pClient = pClient;
    m_pClient->setManagerCallBack(this);
}


class CFileManager :public CManager//文件操作模块
{
public:
    CFileManager(CClientSocket* pClient);
     void OnReceive();//文件操作所有指令
};

CFileManager::CFileManager(CClientSocket* pClient):CManager(pClient)
{

}

void CFileManager::OnReceive()
{
    printf("更具服务器返回指令执行操作");
}

void CManager::OnReceive()
{
}

bool CClientSocket::Connect()
{
    m_pManager->OnReceive();
    return 0;
}


int main()
{//例子
    CClientSocket    socketClient;
    CFileManager    manager(&socketClient);
    socketClient.Connect();

    return 0;
}

 

posted @ 2021-09-03 21:13  紅人  阅读(146)  评论(0编辑  收藏  举报