![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #include <APPLICATIONS/session/Session.hpp> 00029 #include <APPLICATIONS/session/client/TLBinding.hpp> 00030 00031 #include <WNS/StaticFactory.hpp> 00032 #include <WNS/service/qos/QoSClasses.hpp> 00033 00034 using namespace applications::session::client; 00035 00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(applications::session::client::TLBinding, 00037 applications::session::Binding, 00038 "TLBinding", wns::PyConfigViewCreator); 00039 00040 TLBinding::TLBinding(const wns::pyconfig::View& _pyco): 00041 pyco(_pyco), 00042 listenPort(_pyco.get<int>("listenPort")), 00043 domainName(_pyco.get<std::string>("domainName")), 00044 destinationDomainName(_pyco.get<std::string>("destinationDomainName")), 00045 destinationPort(_pyco.get<int>("destinationPort")), 00046 qosClass(_pyco.get<int>("qosClass")), 00047 logger(pyco.get("logger")) 00048 { 00049 tlService = NULL; 00050 session = NULL; 00051 } 00052 00053 TLBinding::~TLBinding() 00054 { 00055 tlService = NULL; 00056 session = NULL; 00057 } 00058 00059 00060 void 00061 TLBinding::registerComponent(applications::node::component::Component* _component, int _sessionIndex) 00062 { 00063 tlService = 00064 _component->getService<wns::service::tl::Service*>(pyco.get<std::string>("tlService")); 00065 tlService->listenOnPort(listenPort, this); 00066 } 00067 00068 void 00069 TLBinding::onConnectionEstablished(wns::service::nl::Address, wns::service::tl::Connection* _connection) 00070 { 00071 session->onConnectionEstablished(_connection); 00072 _connection->registerDataHandler(session); 00073 } 00074 00075 00076 void 00077 TLBinding::registerSession(int _i, applications::session::Session* _session) 00078 { 00079 session = _session; 00080 } 00081 00082 void 00083 TLBinding::initBinding() 00084 { 00085 tlService->openConnection(destinationPort, domainName, destinationDomainName, qosClass, this); 00086 } 00087 00088 void 00089 TLBinding::releaseBinding(wns::service::tl::Connection* _connection) 00090 { 00091 tlService->closeConnection(_connection); 00092 } 00093 00094 void 00095 TLBinding::startListening(wns::service::tl::Service* _tlService) 00096 { 00097 // Not needed for TLBinding. 00098 } 00099 00100 void 00101 TLBinding::onConnectionClosed(wns::service::tl::Connection*) 00102 { 00103 // intentionally left empty 00104 } 00105 00106 void 00107 TLBinding::onConnectionClosedByPeer(wns::service::tl::Connection*) 00108 { 00109 // intentionally left empty 00110 } 00111 00112 void 00113 TLBinding::onConnectionLost(wns::service::tl::Connection*) 00114 { 00115 // intentionally left empty 00116 } 00117 00118 std::string 00119 TLBinding::printAddress() const 00120 { 00121 std::ostringstream tmp; 00122 tmp << destinationDomainName << ":" << destinationPort; 00123 return tmp.str(); 00124 }
1.5.5