本文整理汇总了C++中Worker::CreateNetClient方法的典型用法代码示例。如果您正苦于以下问题:C++ Worker::CreateNetClient方法的具体用法?C++ Worker::CreateNetClient怎么用?C++ Worker::CreateNetClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Worker
的用法示例。
在下文中一共展示了Worker::CreateNetClient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StoreTargetSelection
//.........这里部分代码省略.........
manager = theApp.pView->m_pWorkerView->GetSelectedManager();
if (!manager) {
ErrorMessage("Unexpectedly found no selected manager in " "CPageNetwork::StoreTargetSelection.");
return;
}
// Count the number of assigned targets.
for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) {
for (hifc = m_TTargets.GetChildItem(hmgr); hifc; hifc = m_TTargets.GetNextSiblingItem(hifc)) {
if (GetSelectionCheck(hifc) == TargetChecked)
target_count++;
}
}
// Make sure we are not assigning more targets than we have workers.
if (target_count > manager->WorkerCount(GenericServerType)) {
ErrorMessage("You do not have enough network workers to assign all " "the selected targets.");
// Restore the last selection.
ShowTargetSelection();
// Set the focus to the target list.
::SetFocus(m_TTargets);
return;
}
// The selection will succeed. Remove current network clients.
if (worker = theApp.pView->m_pWorkerView->GetSelectedWorker())
worker->RemoveTargets(GenericNetType);
else
manager->RemoveTargets(GenericNetType);
// Get the assigned local interface to use for the connection.
local_interface_no = m_DInterface.GetCurSel();
// Assign the targets.
// Loop through all managers.
for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) {
// Loop through all interfaces of a manager.
interface_no = 0;
for (hifc = m_TTargets.GetChildItem(hmgr); hifc; hifc = m_TTargets.GetNextSiblingItem(hifc)) {
if (GetSelectionCheck(hifc) == TargetChecked) {
// Are we dealing with a worker or a manager?
if (!worker) {
// A manager is selected. Get the next available
// network server worker.
worker = manager->GetWorker(expected_worker++, GenericServerType);
}
// Get the interface of the selected target from the manager
// whose interface is selected.
memcpy(&new_target,
((Manager *) m_TTargets.GetItemData(hmgr))->GetInterface(interface_no,
GenericNetType),
sizeof(Target_Spec));
// Set the local and remote addresses of the connection.
// The remote address used by the server is stored as the local
// address for some manager's interface.
if (IsType(new_target.type, TCPClientType)) {
strcpy(new_target.tcp_info.remote_address, new_target.name);
// Verify that the locally assigned interface matches the
// selected target's interface.
if (local_interface_no >= manager->InterfaceCount(GenericTCPType)) {
// Use the first TCP interface.
local_interface_no = 0;
m_DInterface.SetCurSel(local_interface_no);
}
} else if (IsType(new_target.type, VIClientType)) {
strcpy(new_target.vi_info.remote_nic_name, new_target.name);
memcpy(&new_target.vi_info.remote_address,
&new_target.vi_info.local_address, VI_ADDRESS_SIZE);
// Verify that the locally assigned interface matches the
// selected target's interface.
if (local_interface_no <= manager->InterfaceCount(GenericTCPType)) {
// Use the first VI interface.
local_interface_no = manager->InterfaceCount(GenericTCPType);
m_DInterface.SetCurSel(local_interface_no);
}
} else {
ErrorMessage("Invalid target type for new target in "
"CPageNetwork::StoreTargetSelection().");
}
worker->AddTarget(&new_target);
// Record information about what local interface the server
// should use.
worker->SetLocalNetworkInterface(local_interface_no);
// Create the corresponding network client.
worker->CreateNetClient((Manager *)
m_TTargets.GetItemData(hmgr), new_target.type);
// Clear the worker pointer so that the next iteration
// through the loop (for a manager with multiple selected
// interfaces) will get the next available network server.
worker = NULL;
}
interface_no++;
}
}
}