source: flair-src/trunk/tools/VrpnBridge/src/main.cpp@ 232

Last change on this file since 232 was 232, checked in by Sanahuja Guillaume, 4 years ago

vrpnbridge

File size: 1.5 KB
Line 
1// created: 2018/03/13
2// filename: main.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: vrpn bridge, to forward it to bth for exemple
10//
11//
12/*********************************************************************/
13#include <vrpn_Connection.h>
14#include <vrpn_Forwarder.h>
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <signal.h>
19
20vrpn_Connection * server_connection;
21vrpn_Connection * client_connection;
22vrpn_StreamForwarder * forwarder;
23
24void sighandler (int signal) {
25 delete forwarder;
26 delete server_connection;
27 delete client_connection;
28 exit(0);
29}
30
31void install_handler (void) {
32 signal( SIGINT, sighandler );
33 signal( SIGKILL, sighandler );
34 signal( SIGTERM, sighandler );
35 signal( SIGPIPE, sighandler );
36}
37
38int main (int argc, char ** argv) {
39
40 int retval;
41
42 server_connection = vrpn_get_connection_by_name ("127.0.0.1:3883");
43 client_connection = vrpn_create_server_connection(3884);
44
45 forwarder = new vrpn_StreamForwarder(server_connection, "target", client_connection, "target");
46
47 retval = forwarder->forward("vrpn_Tracker Pos_Quat", "vrpn_Tracker Pos_Quat");
48 if (retval)
49 fprintf(stderr, "forwarder->forward (vrpn_Tracker Pos_Quat) failed.\n");
50
51 retval = forwarder->forward("vrpn_Base ping_message", "vrpn_Base ping_message");
52 if (retval)
53 fprintf(stderr, "forwarder->forward (vrpn_Base ping_message) failed.\n");
54
55 install_handler();
56
57 while (1) {
58 server_connection->mainloop();
59 client_connection->mainloop();
60 }
61}
Note: See TracBrowser for help on using the repository browser.