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

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

-logging cleanup für vlc

File size: 2.3 KB
RevLine 
[5284]1
[7464]2#include "ariba/config.h"
[5284]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;
[7834]15 //cout << "#tcpip_transports = " << local.tcp.size() << endl;
[5284]16 if (local.tcp.size()==1) {
17 tcp = new tcpip(local.tcp.begin()->value());
[7834]18 //cout << "Started tcpip_transport on port " << local.tcp.begin()->value() << endl;
[5284]19 }
[7041]20
21 #ifdef HAVE_LIBBLUETOOTH
[5284]22 // setup rfcomm transports
23 rfc = NULL;
[7834]24 //cout << "#rfcomm_transports = " << local.rfcomm.size() << endl;
[5284]25 if ( local.rfcomm.size() == 1 ) {
26 rfc = new rfcomm( local.rfcomm.begin()->value() );
[7834]27 //cout << "Started rfcomm_transport on port " << local.rfcomm.begin()->value() << endl;
[5284]28 }
[7041]29 #endif
[5284]30}
31
32transport_peer::~transport_peer() {
33 if (tcp !=NULL ) delete tcp;
[7041]34#ifdef HAVE_LIBBLUETOOTH
[5284]35 if (rfc !=NULL ) delete rfc;
[7041]36#endif
[5284]37}
38
39void transport_peer::start() {
40 if (tcp!=NULL) tcp->start();
[7041]41#ifdef HAVE_LIBBLUETOOTH
[5284]42 if (rfc!=NULL) rfc->start();
[7041]43#endif
[5284]44}
45
46void transport_peer::stop() {
47 if (tcp!=NULL) tcp->stop();
[7041]48#ifdef HAVE_LIBBLUETOOTH
[5284]49 if (rfc!=NULL) rfc->stop();
[7041]50#endif
[5284]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
[7041]57#ifdef HAVE_LIBBLUETOOTH
[5284]58 if (remote->instanceof<rfcomm_endpoint>() && rfc!=NULL) {
59 rfc->send(remote,data,size);
60 } else
[7041]61#endif
[5284]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);
[7041]67#ifdef HAVE_LIBBLUETOOTH
[5284]68 if (rfc!=NULL) rfc->send(endpoints,data,size);
[7041]69#endif
[5284]70}
71
[5614]72void transport_peer::terminate( const address_v* remote ) {
[5284]73 if (remote->instanceof<tcpip_endpoint>() && tcp!=NULL)
[5614]74 tcp->terminate(remote);
[7041]75#ifdef HAVE_LIBBLUETOOTH
[5284]76 if (remote->instanceof<rfcomm_endpoint>() && rfc!=NULL)
[5614]77 rfc->terminate(remote);
[7041]78#endif
[5284]79}
80
81void transport_peer::register_listener( transport_listener* listener ) {
82 if (tcp!=NULL) tcp->register_listener(listener);
[7041]83#ifdef HAVE_LIBBLUETOOTH
[5284]84 if (rfc!=NULL) rfc->register_listener(listener);
[7041]85#endif
[5284]86}
87
88}} // namespace ariba::transport
Note: See TracBrowser for help on using the repository browser.