source: source/ariba/utility/transport/transport_peer.cpp@ 8606

Last change on this file since 8606 was 7834, checked in by Christoph Mayer, 14 years ago

-logging cleanup für vlc

File size: 2.3 KB
Line 
1
2#include "ariba/config.h"
3#include "transport_peer.hpp"
4#include "transport.hpp"
5
6// namespace ariba::transport
7namespace ariba {
8namespace transport {
9
10using namespace ariba::addressing;
11
12transport_peer::transport_peer( endpoint_set& local_set ) : local(local_set) {
13 // setup tcp transports
14 tcp = NULL;
15 //cout << "#tcpip_transports = " << local.tcp.size() << endl;
16 if (local.tcp.size()==1) {
17 tcp = new tcpip(local.tcp.begin()->value());
18 //cout << "Started tcpip_transport on port " << local.tcp.begin()->value() << endl;
19 }
20
21 #ifdef HAVE_LIBBLUETOOTH
22 // setup rfcomm transports
23 rfc = NULL;
24 //cout << "#rfcomm_transports = " << local.rfcomm.size() << endl;
25 if ( local.rfcomm.size() == 1 ) {
26 rfc = new rfcomm( local.rfcomm.begin()->value() );
27 //cout << "Started rfcomm_transport on port " << local.rfcomm.begin()->value() << endl;
28 }
29 #endif
30}
31
32transport_peer::~transport_peer() {
33 if (tcp !=NULL ) delete tcp;
34#ifdef HAVE_LIBBLUETOOTH
35 if (rfc !=NULL ) delete rfc;
36#endif
37}
38
39void transport_peer::start() {
40 if (tcp!=NULL) tcp->start();
41#ifdef HAVE_LIBBLUETOOTH
42 if (rfc!=NULL) rfc->start();
43#endif
44}
45
46void transport_peer::stop() {
47 if (tcp!=NULL) tcp->stop();
48#ifdef HAVE_LIBBLUETOOTH
49 if (rfc!=NULL) rfc->stop();
50#endif
51}
52
53void transport_peer::send( const address_v* remote, const uint8_t* data, size_t size ) {
54 if (remote->instanceof<tcpip_endpoint>() && tcp!=NULL) {
55 tcp->send(remote,data,size);
56 } else
57#ifdef HAVE_LIBBLUETOOTH
58 if (remote->instanceof<rfcomm_endpoint>() && rfc!=NULL) {
59 rfc->send(remote,data,size);
60 } else
61#endif
62 cerr << "Could not send message to " << remote->to_string() << endl;
63}
64
65void transport_peer::send( const endpoint_set& endpoints, const uint8_t* data, size_t size ) {
66 if (tcp!=NULL) tcp->send(endpoints,data,size);
67#ifdef HAVE_LIBBLUETOOTH
68 if (rfc!=NULL) rfc->send(endpoints,data,size);
69#endif
70}
71
72void transport_peer::terminate( const address_v* remote ) {
73 if (remote->instanceof<tcpip_endpoint>() && tcp!=NULL)
74 tcp->terminate(remote);
75#ifdef HAVE_LIBBLUETOOTH
76 if (remote->instanceof<rfcomm_endpoint>() && rfc!=NULL)
77 rfc->terminate(remote);
78#endif
79}
80
81void transport_peer::register_listener( transport_listener* listener ) {
82 if (tcp!=NULL) tcp->register_listener(listener);
83#ifdef HAVE_LIBBLUETOOTH
84 if (rfc!=NULL) rfc->register_listener(listener);
85#endif
86}
87
88}} // namespace ariba::transport
Note: See TracBrowser for help on using the repository browser.