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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <RobotRaconteur.h>
#include "robotraconteur_generated.h"
using namespace RobotRaconteur;
using namespace std;
using namespace com::robotraconteur::testing::TestService1;
using namespace com::robotraconteur::testing::TestService2;
using namespace com::robotraconteur::testing::TestService3;
int main(int argc, char* argv[])
{
if (argc < 2)
{
cout << "Usage for peeridentity: peeridentity url [nodeid]" << endl;
return -1;
}
string url1(argv[1]);
RobotRaconteurNode::s()->SetLogLevelFromEnvVariable();
RR_SHARED_PTR<TcpTransport> c = RR_MAKE_SHARED<TcpTransport>();
if (argc > 2)
{
std::string nodeid1 = (argv[2]);
NodeID id(nodeid1);
RobotRaconteurNode::s()->SetNodeID(NodeID(nodeid1));
try
{
c->LoadTlsNodeCertificate();
}
catch (std::exception&)
{
std::cout << "warning: Could not load node certificate" << std::endl;
}
}
c->EnableNodeAnnounce();
c->EnableNodeDiscoveryListening();
c->SetDefaultConnectTimeout(100000000);
RobotRaconteurNode::s()->SetRequestTimeout(100000000);
RR_SHARED_PTR<LocalTransport> c2 = RR_MAKE_SHARED<LocalTransport>();
RR_SHARED_PTR<HardwareTransport> c5 = RR_MAKE_SHARED<HardwareTransport>();
RobotRaconteurNode::s()->RegisterTransport(c);
RobotRaconteurNode::s()->RegisterTransport(c2);
RobotRaconteurNode::s()->RegisterTransport(c5);
RobotRaconteurNode::s()->RegisterServiceType(RR_MAKE_SHARED<com__robotraconteur__testing__TestService1Factory>());
RobotRaconteurNode::s()->RegisterServiceType(RR_MAKE_SHARED<com__robotraconteur__testing__TestService2Factory>());
cout << RobotRaconteurNode::s()->NodeID().ToString() << endl;
RR_SHARED_PTR<RRObject> o = RobotRaconteurNode::s()->ConnectService(url1);
RR_SHARED_PTR<testroot> oo = rr_cast<testroot>(o);
oo->func3(1.0, 2.3);
// RR_SHARED_PTR<Endpoint> ep = rr_cast<ServiceStub>(o)->GetContext();
if (c->IsTransportConnectionSecure(o))
{
std::cout << "Connection is secure" << std::endl;
if (c->IsSecurePeerIdentityVerified(o))
{
std::cout << "Peer identity is verified: " << c->GetSecurePeerIdentity(o) << std::endl;
}
else
{
std::cout << "Peer identity is not verified" << std::endl;
}
}
else
{
std::cout << "Connection is not secure" << std::endl;
}
RobotRaconteurNode::s()->Shutdown();
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
cout << "Test completed, no errors detected!" << endl;
return 0;
}
|