//*****************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005. All rights reserved.
// Developed by Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//*****************************************************************************
#include <RCF/UdpEndpoint.hpp>
#include <RCF/InitDeinit.hpp>
#include <RCF/UdpClientTransport.hpp>
#include <RCF/UdpServerTransport.hpp>
#include <SF/Registry.hpp>
namespace RCF {
UdpEndpoint::UdpEndpoint(int port) : mPort(port)
{}
UdpEndpoint::UdpEndpoint(const std::string &ip, int port) : mIp(ip), mPort(port)
{}
UdpEndpoint::UdpEndpoint(const UdpEndpoint &rhs) : mIp(rhs.mIp), mPort(rhs.mPort)
{}
boost::shared_ptr<I_Endpoint> UdpEndpoint::clone() const
{
return boost::shared_ptr<I_Endpoint>(new UdpEndpoint(*this));
}
std::string UdpEndpoint::getIp() const
{
return mIp;
}
int UdpEndpoint::getPort() const
{
return mPort;
}
std::auto_ptr<I_ServerTransport> UdpEndpoint::createServerTransport() const
{
//std::auto_ptr< UdpServerTransport > udpTransport(new UdpServerTransport(mPort));
//return std::auto_ptr<I_ServerTransport>(udpTransport);
return std::auto_ptr<I_ServerTransport>(new UdpServerTransport(mPort));
}
std::auto_ptr<I_ClientTransport> UdpEndpoint::createClientTransport() const
{
return std::auto_ptr<I_ClientTransport>(new UdpClientTransport(mIp, mPort));
}
inline void initUdpEndpointSerialization()
{
#ifdef RCF_USE_SF_SERIALIZATION
SF::registerType<UdpEndpoint>("RCF::UdpEndpoint");
SF::registerBaseAndDerived<I_Endpoint, UdpEndpoint>();
#endif
}
RCF_ON_INIT_NAMED( initUdpEndpointSerialization(), InitUdpEndpointSerialization );
} // namespace RCF