source: flair-src/tags/0.2.2/tools/VrpnBridge/src/main.cpp@ 321

Last change on this file since 321 was 321, checked in by Sanahuja Guillaume, 3 years ago

new ip

File size: 1.6 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#include <unistd.h>
20
21vrpn_Connection * server_connection;
22vrpn_Connection * client_connection;
23vrpn_StreamForwarder * forwarder;
24
25void sighandler (int signal) {
26 delete forwarder;
27 delete server_connection;
28 delete client_connection;
29 exit(0);
30}
31
32void install_handler (void) {
33 signal( SIGINT, sighandler );
34 signal( SIGKILL, sighandler );
35 signal( SIGTERM, sighandler );
36 signal( SIGPIPE, sighandler );
37}
38
39int main (int argc, char ** argv) {
40
41 int retval;
42
43 //server_connection = vrpn_get_connection_by_name ("172.26.213.1:3883");
44 server_connection = vrpn_get_connection_by_name ("127.0.0.1:3883");
45 client_connection = vrpn_create_server_connection(3884);
46
47 forwarder = new vrpn_StreamForwarder(server_connection, "target", client_connection, "target");
48
49 retval = forwarder->forward("vrpn_Tracker Pos_Quat", "vrpn_Tracker Pos_Quat");
50 if (retval)
51 fprintf(stderr, "forwarder->forward (vrpn_Tracker Pos_Quat) failed.\n");
52
53 retval = forwarder->forward("vrpn_Base ping_message", "vrpn_Base ping_message");
54 if (retval)
55 fprintf(stderr, "forwarder->forward (vrpn_Base ping_message) failed.\n");
56
57 install_handler();
58
59 while (1) {
60 usleep(5000);
61 server_connection->mainloop();
62 client_connection->mainloop();
63 }
64}
Note: See TracBrowser for help on using the repository browser.