summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Notify/Bug_2561_Regression/Notify_Push_Consumer.cpp
blob: c75a375c65ef8b0bf0b826cb9b0a92df43a11c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ******************************************************************
// Include Section
// ******************************************************************

#include "Notify_Push_Consumer.h"
#include "Notify_Test_Client.h"
#include "orbsvcs/TimeBaseC.h"

// ******************************************************************
// Data Section
// ******************************************************************

// This should be less than or equal to the value of num_events in
// Supplier.cpp
static const int max_events = 70;
static const TimeBase::TimeT PACING = 1000;

// ******************************************************************
// Subroutine Section
// ******************************************************************

Notify_Sequence_Push_Consumer::Notify_Sequence_Push_Consumer (
  Notify_Test_Client& client)
  : count_ (0),
    client_ (client)
{
  this->client_.consumer_start (this);
}


void
Notify_Sequence_Push_Consumer::_connect (
  CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin)
{
  CosNotifyComm::SequencePushConsumer_var objref =
    this->_this ();

  CosNotifyChannelAdmin::ProxySupplier_var proxysupplier =
    consumer_admin->obtain_notification_push_supplier (
    CosNotifyChannelAdmin::SEQUENCE_EVENT,
    proxy_id_);

  this->proxy_ =
    CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow (
    proxysupplier.in ());

  CosNotification::QoSProperties properties (1);
  properties.length (1);
  properties[0].name = CORBA::string_dup (CosNotification::PacingInterval);
  properties[0].value <<= PACING;

  this->proxy_->set_qos (properties);
  this->proxy_->connect_sequence_push_consumer (objref.in ());

  // give ownership to POA
  this->_remove_ref ();
}


void
Notify_Sequence_Push_Consumer::push_structured_events (
  const CosNotification::EventBatch& events)
{
  this->count_ += events.length ();
  if (this->count_ >= max_events)
    {
      this->client_.consumer_done (this);
    }
}