MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / ACE_TMAIN

Function ACE_TMAIN

tests/FACE/Reliability/Subscriber/Subscriber.cpp:10–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include <iostream>
9
10int ACE_TMAIN(int, ACE_TCHAR*[])
11{
12 FACE::RETURN_CODE_TYPE status = FACE::RC_NO_ERROR;
13 FACE::TS::Initialize("face_config.ini", status);
14 FACE::CONNECTION_ID_TYPE connId;
15 FACE::MESSAGE_SIZE_TYPE size;
16
17 FACE::CONNECTION_ID_TYPE connId_INF;
18 FACE::MESSAGE_SIZE_TYPE size_INF;
19 FACE::CONNECTION_DIRECTION_TYPE dir_INF;
20
21 if (!status) {
22 FACE::CONNECTION_DIRECTION_TYPE dir;
23 FACE::TS::Create_Connection("sub", FACE::PUB_SUB, connId, dir, size,
24 FACE::INF_TIME_VALUE, status);
25 FACE::TS::Create_Connection("sub_INF", FACE::PUB_SUB, connId_INF, dir_INF,
26 size_INF, FACE::INF_TIME_VALUE, status);
27 }
28
29 if (!status) {
30 const FACE::TIMEOUT_TYPE timeout = FACE::INF_TIME_VALUE;
31 FACE::TRANSACTION_ID_TYPE txn;
32 Messenger::Message msg;
33 long expected = 0;
34 std::cout << "Subscriber: about to receive_message()" << std::endl;
35 while (expected <= 19) {
36 FACE::TS::Receive_Message(connId, timeout, txn, msg, size, status);
37 if (status != FACE::RC_NO_ERROR) break;
38 std::cout << msg.text.in() << '\t' << msg.count << std::endl;
39 if ((msg.count != expected) && expected > 0) {
40 std::cerr << "ERROR: Expected count " << expected << ", got "
41 << msg.count << std::endl;
42 status = FACE::INVALID_PARAM;
43 break;
44 } else {
45 expected = msg.count + 1;
46 }
47 }
48 }
49
50 // Always destroy connection, but don't overwrite bad status
51 FACE::RETURN_CODE_TYPE destroy_status_INF = FACE::RC_NO_ERROR;
52 FACE::TS::Destroy_Connection(connId_INF, destroy_status_INF);
53 if ((destroy_status_INF != FACE::RC_NO_ERROR) && (!status)) {
54 status = destroy_status_INF;
55 }
56
57 // Always destroy connection, but don't overwrite bad status
58 FACE::RETURN_CODE_TYPE destroy_status = FACE::RC_NO_ERROR;
59 try
60 {
61 FACE::TS::Destroy_Connection(connId, destroy_status);
62 }
63 catch (const CORBA::BAD_PARAM& ex)
64 {
65 ex._tao_print_exception("Exception caught in Subscriber.cpp:");
66 return 1;
67 }

Callers

nothing calls this directly

Calls 6

InitializeFunction · 0.85
Create_ConnectionFunction · 0.85
Receive_MessageFunction · 0.85
Destroy_ConnectionFunction · 0.85
_tao_print_exceptionMethod · 0.80
inMethod · 0.45

Tested by

no test coverage detected