19 #ifndef INCLUDE_RCF_UDPSERVERTRANSPORT_HPP
20 #define INCLUDE_RCF_UDPSERVERTRANSPORT_HPP
25 #include <boost/noncopyable.hpp>
26 #include <boost/shared_ptr.hpp>
28 #include <RCF/Export.hpp>
29 #include <RCF/IpAddress.hpp>
30 #include <RCF/Service.hpp>
31 #include <RCF/ServerTransport.hpp>
32 #include <RCF/IpServerTransport.hpp>
33 #include <RCF/ThreadLibrary.hpp>
37 class UdpServerTransport;
38 class UdpNetworkSession;
40 typedef boost::shared_ptr<UdpServerTransport> UdpServerTransportPtr;
41 typedef boost::shared_ptr<UdpNetworkSession> UdpNetworkSessionPtr;
43 class UdpNetworkSession :
public NetworkSession
47 UdpNetworkSession(UdpServerTransport & transport);
49 int getNativeHandle()
const;
51 typedef UdpNetworkSessionPtr NetworkSessionPtr;
55 ReallocBufferPtr mReadVecPtr;
56 ReallocBufferPtr mWriteVecPtr;
57 IpAddress mRemoteAddress;
58 UdpServerTransport & mTransport;
59 SessionPtr mRcfSessionPtr;
61 friend class UdpServerTransport;
66 const RemoteAddress & getRemoteAddress()
const;
67 ServerTransport & getServerTransport();
68 const RemoteAddress & getRemoteAddress();
70 void setTransportFilters(
71 const std::vector<FilterPtr> &filters);
73 void getTransportFilters(
74 std::vector<FilterPtr> &filters);
76 ByteBuffer getReadByteBuffer();
80 std::vector<ByteBuffer> &byteBuffers);
87 class RCF_EXPORT UdpServerTransport :
88 public ServerTransport,
89 public IpServerTransport,
95 typedef UdpNetworkSession NetworkSession;
96 typedef UdpNetworkSessionPtr NetworkSessionPtr;
101 const IpAddress & ipAddress,
102 const IpAddress & multicastIpAddress = IpAddress());
104 TransportType getTransportType();
112 void setSessionManager(RcfServer & sessionManager);
116 void cycle(
int timeoutMs);
118 void tryReadMessage(NetworkSessionPtr networkSessionPtr);
120 void cycleTransportAndServer(
int timeoutMs);
122 UdpServerTransport & enableSharedAddressBinding();
126 void onServiceAdded(RcfServer &server);
127 void onServiceRemoved(RcfServer &server);
128 void onServerStart(RcfServer &server);
129 void onServerStop(RcfServer &server);
131 RcfServer * mpRcfServer;
132 IpAddress mIpAddress;
133 IpAddress mMulticastIpAddress;
135 unsigned int mPollingDelayMs;
136 bool mEnableSharedAddressBinding;
138 friend class UdpNetworkSession;
144 #endif // ! INCLUDE_RCF_UDPSERVERTRANSPORT_HPP