Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15496461
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: WINDOWS

2009-05-31 18:09:11

浅析vncDesktopThread线程启动流程

WinMain // VC6.0程序入口函数

==>WinVNCAppMain
==>vncMenu *menu = new vncMenu(&server); // 建立vncMenu对象

==>vncMenu::vncMenu(vncServer *server) // 在构造方法中调用m_properties.Init

// vncMenu::WndProc消息处理函数,

// 处理WM_TIMER,WM_SRV_CLIENT_DISCONNECT,WM_COMMAND,

// WM_TRAYNOTIFY,WM_USERCHANGED等系统消息[luther.gliethttp]

==>m_properties.Init(m_server) // 就是调用vncProperties::Init

==>vncProperties::Init 或者 vncProperties::Show
==>vncProperties::Load(BOOL usersettings) // 加载注册表中的设置

==>vncProperties::ApplyUserPrefs 或者 vncServer::SetPort // 加载注册表数值之后,生效所有设置[luther.gliethttp]

==>vncServer::SockConnect(TRUE); // 将执行下面的new vncSockConnect对象创建操作

==>m_socketConn = new vncSockConnect();
==>m_socketConn->Init(this, m_port); // 就是调用vncSockConnect::Init

==>vncSockConnect::Init(vncServer *server, UINT port)
==>m_thread = new vncSockConnectThread;
==>((vncSockConnectThread *)m_thread)->Init(&m_socket, server);
==>vncSockConnectThread::run_undetached
==>VSocket *new_socket = m_socket->Accept(); // 等待client连接本server.

==>m_server->AddClient(new_socket, FALSE, FALSE); // 有新的client发出链接,那么添加该client,就是调用vncServer::AddClient

==>vncServer::AddClient(VSocket *socket, BOOL auth, BOOL shared)
==>client = new vncClient();
==>client->Init(this, socket, auth, shared, clientid); // 就是调用vncClient::Init

==>vncClient::Init(vncServer *server, VSocket *socket, BOOL auth, BOOL shared, vncClientId newid);
==>m_thread = new vncClientThread; // 父类omni_thread将执行下面的构造函数

==>((vncClientThread *)m_thread)->Init(this, m_server, m_socket, auth, shared);
==>omni_thread::start()
==>vncClientThread::run
==>InitAuthenticate()
==>vncClientThread::InitAuthenticate
==>m_server->Authenticated(m_client->GetClientId())
==>vncServer::Authenticated // 把该client从m_unauthClients为auth的链表上摘除,添加自己到m_authClients链表[luther.gliethttp]

==>if (m_desktop == NULL) // 如果vncServer还没创建vncDesktop,那么创建它,这是vncDesktop的唯一一个实例对象[luther.gliethttp].

==>m_desktop = new vncDesktop();
==>m_desktop->Init(this)
==>vncDesktop::Init
==>vncDesktopThread *thread = new vncDesktopThread;
==>thread->Init(this, m_server);
==>vncDesktopThread::Init
==>omni_thread::start_undetached
==>vncDesktopThread::run_undetached
==>ReturnVal(TRUE); // 标识线程正常启动,这样正在等待线程安全启动的vncDesktopThread::Init函数可以正常退出

==>进入loop循环

阅读(1886) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

lantianyu5202011-03-03 12:06:14

大哥,想看你浅析下loop循环里面的细节啊。