Пример #1
0
 void on_message(proton::event &e) {
     proton::message &msg = e.message();
     msg.body().decode() >> received_content_;
     received_bytes_ += received_content_.size();
     if (received_ < total_) {
         received_++;
     }
     e.delivery().settle();
     if (received_ == total_) {
         e.receiver().close();
         e.connection().close();
     }
 }
Пример #2
0
 void on_message(proton::event &e) {
     proton::message& msg = e.message();
     if (msg.id().get<uint64_t>() < received)
         return; // ignore duplicate
     if (expected == 0 || received < expected) {
         std::cout << msg.body() << std::endl;
         received++;
     }
     if (received == expected) {
         e.receiver().close();
         e.connection().close();
         if (!!acceptor) acceptor.close();
     }
 }
Пример #3
0
    void 
    on_message ( proton::event &e ) 
    {
      log ( "on_message" );

      double receive_timestamp = get_timestamp();

      proton::message& msg = e.message();

      double send_timestamp = msg.body().get<double>();
      double latency = receive_timestamp - send_timestamp;

      fprintf ( output_fp, "latency %.6lf\n", latency );

      if ( ! received )
      {
        rr_init ( & resource_reporter );
      }

      if ( (expected == 0)
           || 
           (expected == -1)
           || 
           (received < expected)
         ) 
      {
        received++;
        if ( ! ( received % report_frequency ) )
        {
          report ( output_fp );
        }

        if (received == expected) 
        {
          log ( "closing receiver and connection." );
          e.receiver().close();
          e.connection().close();
          char filename[1000];
          sprintf ( filename, "/tmp/simple_recv_%d_is_done", getpid() );
          FILE * fp = fopen ( filename, "w" );
          fprintf ( fp, ":-)\n" );
          fclose ( fp );
        }
      }
    }