prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Client const & client)
{
- // typedef senf::ClientSocketHandle<MakeSocketPolicy<INet4AddressingPolicy>::policy > v4Socket;
- if( senf::check_socket_cast<TCPv4ServerSocketHandle::ClientSocketHandle>( client.handle())) {
- os<<senf::dynamic_socket_cast<TCPv4ServerSocketHandle::ClientSocketHandle>( client.handle()).peer();
- }
- else if( senf::check_socket_cast<TCPv6ServerSocketHandle::ClientSocketHandle>( client.handle())) {
- os<<senf::dynamic_socket_cast<TCPv6ServerSocketHandle::ClientSocketHandle>( client.handle()).peer();
- }
- else{
- os<<((void *)&client);
- }
+ typedef ClientSocketHandle< MakeSocketPolicy<
+ INet4AddressingPolicy,ConnectedCommunicationPolicy>::policy > V4Socket;
+ typedef ClientSocketHandle< MakeSocketPolicy<
+ INet6AddressingPolicy,ConnectedCommunicationPolicy>::policy > V6Socket;
+
+ if (check_socket_cast<V4Socket>(client.handle()))
+ os << dynamic_socket_cast<V4Socket>(client.handle()).peer();
+ else if (check_socket_cast<V6Socket>(client.handle()))
+ os << dynamic_socket_cast<V6Socket>(client.handle()).peer();
+ else
+ os << static_cast<void const *>(&client);
+
return os;
}
+
prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Client * client)
{
- return os<<*client;
+ return os << *client;
}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "Server.mpp"
virtual ~ClientReader() = 0;
+ // Called by subclasses to get information from the Client
+
Client & client() const;
std::string promptString() const;
ClientHandle handle() const;
std::ostream & stream() const;
+
+ // Called by subclasses to perform actions in the Client
+
void stopClient();
-
void handleInput(std::string const & input) const;
+ // Called by the Client
+
void disablePrompt();
void enablePrompt();
void translate(std::string & data);
template <class Target, class Source>
prefix_ Target senf::dynamic_socket_cast(Source handle)
{
- BOOST_STATIC_ASSERT((
- boost::is_convertible<Source*,FileHandle*>::value &&
- boost::is_convertible<Target*,FileHandle*>::value &&
- ( boost::is_convertible<Source,Target>::value ||
- boost::is_convertible<Target,Source>::value ) ));
+// BOOST_STATIC_ASSERT((
+// boost::is_convertible<Source*,FileHandle*>::value &&
+// boost::is_convertible<Target*,FileHandle*>::value &&
+// ( boost::is_convertible<Source,Target>::value ||
+// boost::is_convertible<Target,Source>::value ) ));
try {
return Target::cast_dynamic(handle);
}
template <class Target, class Source>
prefix_ bool senf::check_socket_cast(Source handle)
{
- BOOST_STATIC_ASSERT((
- boost::is_convertible<Source*,FileHandle*>::value &&
- boost::is_convertible<Target*,FileHandle*>::value &&
- ( boost::is_convertible<Source,Target>::value ||
- boost::is_convertible<Target,Source>::value ) ));
+// BOOST_STATIC_ASSERT((
+// boost::is_convertible<Source*,FileHandle*>::value &&
+// boost::is_convertible<Target*,FileHandle*>::value &&
+// ( boost::is_convertible<Source,Target>::value ||
+// boost::is_convertible<Target,Source>::value ) ));
// we don't have a non-throwing variant of cast_dynamic
// for two reasons:
// a) since the handle is passed back by value, we cannot return
>::policy OtherSocketPolicy;
typedef senf::SocketHandle<OtherSocketPolicy> OtherSocketHandle;
+ typedef senf::MakeSocketPolicy<
+ senf::test::SomeCommunicationPolicy,
+ senf::test::SomeAddressingPolicy
+ >::policy AnotherSocketPolicy;
+ typedef senf::SocketHandle<AnotherSocketPolicy> AnotherSocketHandle;
+
{
MySocketHandle myh;
OtherSocketHandle osh (myh);
SomeSocketHandle ssh = senf::static_socket_cast<SomeSocketHandle>(osh);
BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
+ BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<AnotherSocketHandle>(osh) );
typedef senf::SocketHandle< senf::MakeSocketPolicy<
OtherSocketPolicy,
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
-
namespace test {
struct SomeAddressingPolicy : public senf::AddressingPolicyBase