User Manual, Developers Guide and API Documentation

TcpClientListenerBinding.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * TCP Client Listener Binding                                                *
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/TcpClientListenerBinding.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 TcpClientListenerBinding::TcpClientListenerBinding(int _listenPort):
00021     listenPort(_listenPort)
00022 {
00023     std::cout<<"New TcpClientListenerBinding created on my socket= "<< ownAddress << ":" << listenPort<<std::endl;
00024 }
00025 
00026 void TcpClientListenerBinding::sendData(const wns::osi::PDUPtr&)
00027 {
00028     // intentionally left empty
00029 }
00030 
00031 void TcpClientListenerBinding::registerComponent(wns::node::component::Component* /*_component*/)
00032 {
00033 // intentionally left empty
00034 
00035 //  component = _component;
00036 //  tcpService =
00037 //      component->getService<wns::service::tl::Service*>(
00038 //          pyco.get<std::string>("tcpService"));
00039 //  tcpService->listenOnPort(listenPort, this);
00040 }
00041 void
00042 TcpClientListenerBinding::registerTcpService(wns::service::tl::Service* _tcpService)
00043 {
00044     _tcpService->listenOnPort(listenPort, this);
00045 }
00046 
00047 void TcpClientListenerBinding::onConnectionEstablished(wns::service::nl::Address _address, wns::service::tl::Connection* _connection)
00048 {
00049     ownAddress = _address;
00050     _connection->registerDataHandler(this);
00051 }
00052 
00053 void TcpClientListenerBinding::onData(const wns::osi::PDUPtr& _data)
00054 {
00055     assure(listener, "No listener set.");
00056     MESSAGE_BEGIN(NORMAL, log, m, "Received " << _data->getLengthInBits()/8 << " bytes"); // "from ?"
00057     m << " on my socket=" << ownAddress << ":" << listenPort;
00058     MESSAGE_END();
00059     listener->onData(_data);
00060 }
00061 
00062 void TcpClientListenerBinding::registerListener(constanze::Listener* _listener)
00063 {
00064     listener = _listener;
00065 }
00066 
00067 void TcpClientListenerBinding::initBinding(constanze::StartTrigger* )
00068 {
00069     // intentionally left empty
00070 }
00071 
00072 void TcpClientListenerBinding::releaseBinding(constanze::StopTrigger*)
00073 {
00075 }
00076 
00077 void TcpClientListenerBinding::onConnectionClosed(wns::service::tl::Connection*)
00078 {
00079     // TCP has no connection that can be closed
00080     // intentionally left empty
00081 }
00082 
00083 void TcpClientListenerBinding::onConnectionClosedByPeer(wns::service::tl::Connection*)
00084 {
00085     // TCP has no connection that can be closed
00086     // intentionally left empty
00087 }
00088 
00089 void TcpClientListenerBinding::onConnectionLost(wns::service::tl::Connection*)
00090 {
00091     // TCP has no connection that can be closed
00092     // intentionally left empty
00093 }
00094 
00095 std::string
00096 TcpClientListenerBinding::printAddress() const
00097 {
00098         std::ostringstream tmp;
00099         tmp << ownAddress << ":" << listenPort;
00100         return tmp.str();
00101 }
00102 
00103 

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