本文整理汇总了C++中Consumer::disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ Consumer::disconnect方法的具体用法?C++ Consumer::disconnect怎么用?C++ Consumer::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Consumer
的用法示例。
在下文中一共展示了Consumer::disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testDrop
void testDrop (beast::Journal j)
{
testcase ("Warn/drop");
TestLogic logic (j);
Charge const fee (dropThreshold + 1);
beast::IP::Endpoint const addr (
beast::IP::Endpoint::from_string ("207.127.82.2"));
{
Consumer c (logic.newInboundEndpoint (addr));
// Create load until we get a warning
for (std::size_t n (maxLoopCount); true; --n)
{
if (n == 0)
{
fail ("Loop count exceeded without warning");
return;
}
if (c.charge (fee) == warn)
{
pass ();
break;
}
++logic.clock ();
}
// Create load until we get dropped
for (std::size_t n (maxLoopCount); true; --n)
{
if (n == 0)
{
fail ("Loop count exceeded without dropping");
return;
}
if (c.charge (fee) == drop)
{
pass ();
break;
}
++logic.clock ();
}
}
{
Consumer c (logic.newInboundEndpoint (addr));
expect (c.disconnect ());
}
for (std::size_t n (maxLoopCount); true; --n)
{
Consumer c (logic.newInboundEndpoint (addr));
if (n == 0)
{
fail ("Loop count exceeded without expiring black list");
return;
}
if (c.disposition() != drop)
{
pass ();
break;
}
}
}
示例2: testDrop
void testDrop (beast::Journal j)
{
testcase ("Warn/drop");
TestLogic logic (j);
Charge const fee (dropThreshold + 1);
beast::IP::Endpoint const addr (
beast::IP::Endpoint::from_string ("207.127.82.2"));
{
Consumer c (logic.newInboundEndpoint (addr));
// Create load until we get a warning
int n = 10000;
while (--n >= 0)
{
if (n == 0)
{
fail ("Loop count exceeded without warning");
return;
}
if (c.charge (fee) == warn)
{
pass ();
break;
}
++logic.clock ();
}
// Create load until we get dropped
while (--n >= 0)
{
if (n == 0)
{
fail ("Loop count exceeded without dropping");
return;
}
if (c.charge (fee) == drop)
{
// Disconnect abusive Consumer
expect (c.disconnect ());
break;
}
++logic.clock ();
}
}
// Make sure the consumer is on the blacklist for a while.
{
Consumer c (logic.newInboundEndpoint (addr));
logic.periodicActivity();
if (c.disposition () != drop)
{
fail ("Dropped consumer not put on blacklist");
return;
}
}
// Makes sure the Consumer is eventually removed from blacklist
bool readmitted = false;
{
// Give Consumer time to become readmitted. Should never
// exceed expiration time.
std::size_t n (secondsUntilExpiration + 1);
while (--n > 0)
{
++logic.clock ();
logic.periodicActivity();
Consumer c (logic.newInboundEndpoint (addr));
if (c.disposition () != drop)
{
readmitted = true;
break;
}
}
}
if (readmitted == false)
{
fail ("Dropped Consumer left on blacklist too long");
return;
}
pass();
}
示例3: attributes
//.........这里部分代码省略.........
receiver->connect (pub);
// **************** THAT COMPLETES THE FEDERATION SETUP
// **************** HERE STARTS THE CLIENT SETUP
// First let us create a consumer and connect it to the event
// channel
Consumer consumer (valuetype);
RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
event_channel->for_consumers ();
consumer.connect (consumer_admin.in ());
// **************** THAT COMPLETES THE CLIENT SETUP
// **************** HERE STARTS THE EVENT LOOP
// Wait for events, including incoming multicast data.
// We could also use orb->run(), but that will not let us
// terminate the application in a nice way.
for (int i = 0; i != 100; ++i)
{
CORBA::Boolean there_is_work =
orb->work_pending ();
if (there_is_work)
{
// We use a TAO extension. The CORBA mechanism does not
// provide any decent way to control the duration of
// perform_work() or work_pending(), so just calling
// them results in a spin loop.
ACE_Time_Value tv (0, 50000);
orb->perform_work (tv);
}
ACE_Time_Value tv (0, 100000);
ACE_OS::sleep (tv);
if (consumer.event_count () == 25)
{
break;
}
}
// **************** THAT COMPLETES THE EVENT LOOP
// **************** HERE STARTS THE CLEANUP CODE
consumer.disconnect ();
// Now let us close the Receiver
receiver->shutdown ();
int const r = mcast_eh.shutdown ();
if (r == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Closing MCast event handler\n"), 1);
}
// The event channel must be destroyed, so it can release its
// resources, and inform all the clients that are still
// connected that it is going away.
event_channel->destroy ();
// Deactivating the event channel implementation is not strictly
// required, the POA will do it for us, but it is good manners:
{
// Using _this() activates with the default POA, we must gain
// access to that POA to deactivate the object.
// Notice that we 'know' that the default POA for this servant
// is the root POA, but the code is more robust if we don't
// rely on that.
PortableServer::POA_var poa =
ec_impl._default_POA ();
// Get the Object Id used for the servant..
PortableServer::ObjectId_var oid =
poa->servant_to_id (&ec_impl);
// Deactivate the object
poa->deactivate_object (oid.in ());
}
// Now we can destroy the POA, the flags mean that we want to
// wait until the POA is really destroyed
poa->destroy (1, 1);
// Finally destroy the ORB
orb->destroy ();
// **************** THAT COMPLETES THE CLEANUP CODE
ACE_DEBUG ((LM_DEBUG,
"UDP receiver ready\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Service");
return 1;
}
return 0;
}