| 64 | } |
| 65 | |
| 66 | int ACE_TMAIN(int, ACE_TCHAR*[]) |
| 67 | { |
| 68 | FACE::RETURN_CODE_TYPE status = FACE::RC_NO_ERROR; |
| 69 | FACE::TS::Initialize("face_config.ini", status); |
| 70 | FACE::MESSAGE_SIZE_TYPE max_msg_size = 0; |
| 71 | |
| 72 | if (!status) { |
| 73 | FACE::CONNECTION_DIRECTION_TYPE dir; |
| 74 | FACE::TS::Create_Connection("sub", FACE::PUB_SUB, connId, dir, max_msg_size, FACE::INF_TIME_VALUE, status); |
| 75 | if (status != FACE::RC_NO_ERROR) return static_cast<int>(status); |
| 76 | } |
| 77 | |
| 78 | //First test receive header for a callback processed message |
| 79 | //Should receive 10 messages, process/receive their headers then unregister callback |
| 80 | ACE_DEBUG((LM_INFO, "Subscriber: about to Register_Callback()\n")); |
| 81 | FACE::TS::Register_Callback(connId, 0, callback, max_msg_size, status); |
| 82 | if (status != FACE::RC_NO_ERROR) return static_cast<int>(status); |
| 83 | |
| 84 | // Second test receive header after a Receive_Message processed message |
| 85 | bool receiveMessageHappened = false; |
| 86 | int recv_msg_count = 0; |
| 87 | if (!status) { |
| 88 | FACE::TRANSACTION_ID_TYPE txn; |
| 89 | HeaderTest::Message msg; |
| 90 | std::cout << "Subscriber: about to Receive_Message()" << std::endl; |
| 91 | while (expected <= 19) { |
| 92 | FACE::TS::Receive_Message(connId, timeout, txn, msg, max_msg_size, status); |
| 93 | if (status != FACE::RC_NO_ERROR) break; |
| 94 | std::cout << "Receive_Message: (the " << recv_msg_count << " time): " << msg.text.in() |
| 95 | << "\t" << msg.count << "\tmsg_instance_guid: " << std::hex << msg.msg_instance_guid |
| 96 | << std::dec << "\tttid: " << txn << std::endl; |
| 97 | ++recv_msg_count; |
| 98 | receiveMessageHappened = true; |
| 99 | FACE::TS::MessageHeader hdr; |
| 100 | FACE::TS::Receive_Message(connId, timeout, txn, hdr, sizeof(FACE::TS::MessageHeader), status); |
| 101 | if (status != FACE::RC_NO_ERROR) { |
| 102 | std::cout << "ERROR: Receive_Message for header failed for tid: " << txn << " with status: " << status << std::endl; |
| 103 | break; |
| 104 | } |
| 105 | std::cout << "Message Header - tid: " << txn |
| 106 | << "\n\tplatform view guid: " << hdr.platform_view_guid |
| 107 | << "\n\tsource timestamp: " << hdr.message_timestamp |
| 108 | << "\n\tinstance guid: " << std::hex << hdr.message_instance_guid |
| 109 | << "\n\tsource guid: " << std::dec << hdr.message_source_guid |
| 110 | << "\n\tvalidity " << hdr.message_validity << std::endl; |
| 111 | if (hdr.message_source_guid != 9645061) { |
| 112 | std::cout << "ERROR: Receive_Message for header failed. Header source guid " << hdr.message_source_guid |
| 113 | << " != 9645061" << std::endl; |
| 114 | status = FACE::INVALID_PARAM; |
| 115 | return status; |
| 116 | } |
| 117 | if (hdr.message_instance_guid != msg.msg_instance_guid) { |
| 118 | std::cout << "ERROR: Receive_Message for header failed. message_instance_guid " << std::hex << hdr.message_instance_guid |
| 119 | << " != " << msg.msg_instance_guid << std::endl; |
| 120 | status = FACE::INVALID_PARAM; |
| 121 | return status; |
| 122 | } |
| 123 | expected = msg.count + 1; |
nothing calls this directly
no test coverage detected