Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1156933
  • 博文数量: 222
  • 博客积分: 5262
  • 博客等级: 大校
  • 技术积分: 3028
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-22 19:10
文章分类

全部博文(222)

文章存档

2012年(2)

2011年(192)

2010年(28)

分类:

2011-03-03 12:06:43

浅析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循环

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