User Manual, Developers Guide and API Documentation

UdpClientListenerBinding.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * UDP ClientListenerBinding                                                  *
00003  * __________________________________________________________________________ *
00004  *                                                                            *
00005  * Copyright (C) 2005                                                         *
00006  * Lehrstuhl fuer Kommunikationsnetze (ComNets)                               *
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany                                 *
00008  * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242                   *
00009  * email: wns@comnetsrwth-aachen.de, www: http://wns.comnets.rwth-aachen.de/  *
00010  *****************************************************************************/
00011 
00012 #include <CONSTANZE/UdpClientListenerBinding.hpp>
00013 
00014 #include <WNS/service/nl/Address.hpp>
00015 #include <WNS/service/tl/PortPool.hpp>
00016 #include <WNS/module/Base.hpp>
00017 
00018 using namespace constanze;
00019 
00020 UdpClientListenerBinding::UdpClientListenerBinding(int _listenPort):
00021     listenPort(_listenPort)
00022 {
00023     std::cout<<"New UdpClientListenerBinding created on my socket= "<< ownAddress << ":" << listenPort<<std::endl;
00024 }
00025 
00026 void
00027 UdpClientListenerBinding::sendData(const wns::osi::PDUPtr&)
00028 {
00029     // intentionally left empty
00030 }
00031 
00032 void
00033 UdpClientListenerBinding::registerComponent(wns::node::component::Component* /*_component*/)
00034 {
00035 // intentionally left empty
00036 
00037 //  component = _component;
00038 //  udpService =
00039 //      component->getService<wns::service::tl::Service*>(
00040 //          pyco.get<std::string>("udpService"));
00041 //  udpService->listenOnPort(listenPort, this);
00042 }
00043 void
00044 UdpClientListenerBinding::registerUdpService(wns::service::tl::Service* _udpService)
00045 {
00046     _udpService->listenOnPort(listenPort, this);
00047 }
00048 
00049 void
00050 UdpClientListenerBinding::onConnectionEstablished(wns::service::nl::Address _address, wns::service::tl::Connection* _connection)
00051 {
00052     ownAddress = _address;
00053     _connection->registerDataHandler(this);
00054 }
00055 
00056 void
00057 UdpClientListenerBinding::onData(const wns::osi::PDUPtr& _data)
00058 {
00059     assure(listener, "No listener set.");
00060     MESSAGE_BEGIN(NORMAL, log, m, "Received " << _data->getLengthInBits()/8 << " bytes"); // "from ?"
00061     m << " on my socket=" << ownAddress << ":" << listenPort;
00062     MESSAGE_END();
00063     listener->onData(_data);
00064 }
00065 
00066 void
00067 UdpClientListenerBinding::registerListener(constanze::Listener* _listener)
00068 {
00069     listener = _listener;
00070 }
00071 
00072 void
00073 UdpClientListenerBinding::initBinding(constanze::StartTrigger* )
00074 {
00075     // intentionally left empty
00076 }
00077 
00078 void
00079 UdpClientListenerBinding::releaseBinding(constanze::StopTrigger*)
00080 {
00082 }
00083 
00084 void
00085 UdpClientListenerBinding::onConnectionClosed(wns::service::tl::Connection*)
00086 {
00087     // UDP has no connection that can be closed
00088     // intentionally left empty
00089 }
00090 
00091 void
00092 UdpClientListenerBinding::onConnectionClosedByPeer(wns::service::tl::Connection*)
00093 {
00094     // UDP has no connection that can be closed
00095     // intentionally left empty
00096 }
00097 
00098 void
00099 UdpClientListenerBinding::onConnectionLost(wns::service::tl::Connection*)
00100 {
00101     // UDP has no connection that can be closed
00102     // intentionally left empty
00103 }
00104 
00105 std::string
00106 UdpClientListenerBinding::printAddress() const
00107 {
00108         std::ostringstream tmp;
00109         tmp << ownAddress << ":" << listenPort;
00110         return tmp.str();
00111 }
00112 
00113 

Generated on Sat May 26 03:32:14 2012 for openWNS by  doxygen 1.5.5