本文整理汇总了C++中NetworkManager类的典型用法代码示例。如果您正苦于以下问题:C++ NetworkManager类的具体用法?C++ NetworkManager怎么用?C++ NetworkManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NetworkManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleDhcpMsg
/**
* Handles a DHCP message.
*
* @returns true if handled, false if not.
* @param uMsgType The message type.
* @param pDhcpMsg The DHCP message.
* @param cb The size of the DHCP message.
*/
bool VBoxNetDhcp::handleDhcpMsg(uint8_t uMsgType, PCRTNETBOOTP pDhcpMsg, size_t cb)
{
if (pDhcpMsg->bp_op == RTNETBOOTP_OP_REQUEST)
{
NetworkManager *networkManager = NetworkManager::getNetworkManager();
switch (uMsgType)
{
case RTNET_DHCP_MT_DISCOVER:
return networkManager->handleDhcpReqDiscover(pDhcpMsg, cb);
case RTNET_DHCP_MT_REQUEST:
return networkManager->handleDhcpReqRequest(pDhcpMsg, cb);
case RTNET_DHCP_MT_DECLINE:
return networkManager->handleDhcpReqDecline(pDhcpMsg, cb);
case RTNET_DHCP_MT_RELEASE:
return networkManager->handleDhcpReqRelease(pDhcpMsg, cb);
case RTNET_DHCP_MT_INFORM:
debugPrint(0, true, "Should we handle this?");
break;
default:
debugPrint(0, true, "Unexpected.");
break;
}
}
return false;
}
示例2: tst_networkInstance
void Tst_connectionagent::tst_networkInstance()
{
NetworkManager *netman = NetworkManagerFactory::createInstance();
QString currentState = netman->state();
QConnectionAgent::instance();
QVERIFY(currentState == netman->state());
}
示例3: threadConnexion
void* NetworkManager::threadConnexion(void* arguments)
{
NetworkManager * networkManager = static_cast<NetworkManager *>(arguments) ;
while ((enet_host_service (networkManager->client,&networkManager->eventClient, 10) >= 0 ) && (networkManager->endThread == false ) )
{
switch (networkManager->eventClient.type)
{
case ENET_EVENT_TYPE_CONNECT:
networkManager->callback((XSILIUM_ALL * 1000) + ID_CONNEXION);
break;
case ENET_EVENT_TYPE_RECEIVE:
{
MessagePacket * message = new MessagePacket();
std::istringstream archive_stream(std::string((char*)networkManager->eventClient.packet->data));
boost::archive::text_iarchive archive(archive_stream);
archive >> message;
networkManager->callback(message->getOpcode(),message);
break;
}
case ENET_EVENT_TYPE_DISCONNECT:
networkManager->callback((XSILIUM_ALL * 1000 ) + ID_DECONEXION);
networkManager->endThread = true;
break;
default:
break;
}
enet_packet_destroy (networkManager->eventClient.packet);
}
return NULL;
}
示例4: send
DWORD WINAPI NetworkManager::send(LPVOID lpParam)
{
NetworkManager* manager = (NetworkManager*)lpParam;
const NetworkDevice& device = manager->getDevice();
NetworkPacketQueue& outbox = manager->outbox;
try
{
while (device.isConnected())
{
while (!outbox.empty())
{
const NetworkPacket& packet = outbox.front();
device.send((char*)&packet, packet.size + NetworkPacket::getHeaderSize());
outbox.pop();
}
::Sleep(1);
}
}
catch (const Exception& ex)
{
Console::out << ex.what() << Console::endl;
}
return 0;
}
示例5: LOG4CXX_TRACE
bool Resources::fileExists(const string &path, InstanceID instanceId, const shared_ptr<Query>& query)
{
LOG4CXX_TRACE(logger, "Resources::fileExists. Checking file '" << path << "'");
NetworkManager* networkManager = NetworkManager::getInstance();
if (instanceId == query->getInstanceID())
{
LOG4CXX_TRACE(logger, "Resources::fileExists. Instance id " << instanceId << " is local instance. Returning result.");
return checkFileExists(path);
}
else
{
LOG4CXX_TRACE(logger, "Resources::fileExists. Instance id " << instanceId << " is remote instance. Requesting result.");
FileExistsResourcesCollector* collector = new FileExistsResourcesCollector();
uint64_t id = 0;
{
ScopedMutexLock lock(_lock);
id = ++_lastResourceCollectorId;
_resourcesCollectors[id] = collector;
}
shared_ptr<MessageDesc> msg = make_shared<MessageDesc>(mtResourcesFileExistsRequest);
shared_ptr<scidb_msg::ResourcesFileExistsRequest> request =
msg->getRecord<scidb_msg::ResourcesFileExistsRequest>();
msg->setQueryID(0);
request->set_resource_request_id(id);
request->set_file_path(path);
networkManager->sendMessage(instanceId, msg);
LOG4CXX_TRACE(logger, "Resources::fileExists. Waiting while instance return result for collector " << id);
try
{
Semaphore::ErrorChecker errorChecker = bind(&Query::validateQueryPtr, query);
collector->_collectorSem.enter(1, errorChecker);
}
catch (...)
{
LOG4CXX_TRACE(logger, "Resources::fileExists. Waiting for result of collector " << id <<
" interrupter by error");
{
ScopedMutexLock lock(_lock);
delete _resourcesCollectors[id];
_resourcesCollectors.erase(id);
}
throw;
}
LOG4CXX_TRACE(logger, "Resources::fileExists. Returning result of collector " << id);
bool result;
{
ScopedMutexLock lock(_lock);
result = ((FileExistsResourcesCollector*) _resourcesCollectors[id])->_instancesMap[instanceId];
delete _resourcesCollectors[id];
_resourcesCollectors.erase(id);
}
return result;
}
}
示例6: main
int main()
{
Link link("L1", 10000000, 0.01, 64000);
Node node1("H1");
Node node2("H2");
NetworkManager* nm = NetworkManager::getInstance();
nm->registerLink(link);
nm->registerNode(node1);
nm->registerNode(node2);
nm->connectLink("L1", "H1", "H2");
Flow flow("F1", "H1", "H2", 20000000, TCP_RENO_t, 1);
nm->registerFlow(flow);
EventQueue* eq = EventQueue::getInstance();
eq->run();
Logger * logger = Logger::getInstance();
delete logger;
return EXIT_SUCCESS;
}
示例7: checkNseMessageCallback
/**
* Static Callback called when network size estimate is updated.
*/
void NetworkManager::checkNseMessageCallback (void *cls, struct GNUNET_TIME_Absolute timestamp,
double estimate, double std_dev)
{
NetworkManager* networkInstance = (NetworkManager*)cls;
Q_ASSERT(networkInstance);
networkInstance->checkNseMessage(timestamp,estimate,std_dev);
}
示例8:
void
NetworkManager::notifyConnectCallback (void *cls, const struct GNUNET_PeerIdentity *peer)
{
NetworkManager* networkInstance = (NetworkManager*)cls;
Q_ASSERT(networkInstance);
networkInstance->notifyConnect(peer);
}
示例9: peerinfoProcessorCallback
/**
* Static Callback called when we have a information about a peer.
*/
void NetworkManager::peerinfoProcessorCallback (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Message *hello,
const char *err_msg)
{
NetworkManager* networkInstance = (NetworkManager*)cls;
Q_ASSERT(networkInstance);
networkInstance->peerinfoProcessor(peer, hello, err_msg);
}
示例10: testWifiReceiveStatus
void testWifiReceiveStatus(const char* ipAddressLocal, const char* ipAddressRemote)
{
NetworkManager* ourNetworkManager = new NetworkManager;
ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP);
NetworkChunk* chunk = new NetworkChunk;
ourNetworkManager->getData("USBSocket", chunk);
Status ourStatus(*chunk);
}
示例11:
int CommandListener::WifiRemoveNetworkCmd::runCommand(SocketClient *cli,
int argc, char **argv) {
NetworkManager *nm = NetworkManager::Instance();
WifiController *wc = (WifiController *) nm->findController("WIFI");
if (wc->removeNetwork(atoi(argv[1])))
cli->sendMsg(ResponseCode::OperationFailed, "Failed to remove network", true);
else {
cli->sendMsg(ResponseCode::CommandOkay, "Network removed.", false);
}
return 0;
}
示例12: while
DWORD WINAPI NetworkManager::start(LPVOID lpParam)
{
HANDLE threads[2];
unsigned long exitCodes[2];
NetworkManager* manager = (NetworkManager*)lpParam;
NetworkDevice device = manager->getDevice();
while (!manager->quit)
{
// connect to server
while (!device.isConnected() && !manager->quit)
device.connect(manager->server, manager->port);
if (device.isConnected())
{
// start send and receive threads
threads[0] = ::CreateThread(0, 0, NetworkManager::send, lpParam, 0, 0);
threads[1] = ::CreateThread(0, 0, NetworkManager::receive, lpParam, 0, 0);
// monitor threads
while (device.isConnected())
{
::Sleep(100);
// check if threads are still alive
for (unsigned i = 0; i < 2; ++i)
::GetExitCodeThread(threads[i], &exitCodes[i]);
// if quit flag is set or threads have finished
if (manager->quit || exitCodes[0] != STILL_ACTIVE || exitCodes[1] != STILL_ACTIVE)
{
device.disconnect();
::WaitForMultipleObjects(2, threads, true, INFINITE);
for (unsigned i = 0; i < 2; ++i)
::CloseHandle(threads[i]);
manager->inbox.clear();
manager->onDisconnect();
manager->outbox.clear();
}
}
}
}
return 0;
}
示例13: sprintf
int CommandListener::WifiCreateNetworkCmd::runCommand(SocketClient *cli,
int argc, char **argv) {
NetworkManager *nm = NetworkManager::Instance();
WifiController *wc = (WifiController *) nm->findController("WIFI");
WifiNetwork *wn;
if (!(wn = wc->createNetwork()))
cli->sendMsg(ResponseCode::OperationFailed, "Failed to create network", true);
else {
char tmp[128];
sprintf(tmp, "Created network id %d.", wn->getNetworkId());
cli->sendMsg(ResponseCode::CommandOkay, tmp, false);
}
return 0;
}
示例14: ATSstatusChangeCallback
void NetworkManager::ATSstatusChangeCallback (void *cls,
const struct GNUNET_HELLO_Address *address,
int address_active,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
{
NetworkManager* networkInstance = (NetworkManager*)cls;
Q_ASSERT(networkInstance);
networkInstance->peerATSstatusChange(address,address_active, bandwidth_in, bandwidth_out, ats,ats_count);
}
示例15: testWifiSendCommandNoMessage
void testWifiSendCommandNoMessage(const char* ipAddressLocal, const char* ipAddressRemote)
{
NetworkManager* ourNetworkManager = new NetworkManager;
ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP);
//make and fill command with data
Command *ourCommand = new Command;
ourCommand->setCommandType(CommandType::DRIVE_BACKWARD);
//turn command into NetworkChunk
NetworkChunk* ourNetworkChunk = new NetworkChunk;
*ourNetworkChunk = ourCommand->toNetworkChunk();
//send NetworkChunk
ourNetworkManager->sendData("USBSocket", ourNetworkChunk);
}