ServerHandle::ClientHandle client (handle_.accept());
boost::intrusive_ptr<Client> p (new Client(*this, client));
clients_.insert( p );
- SENF_LOG(( "Registered new client " << p.get() ));
+ SENF_LOG(( "Registered new client " << client.peer() ));
}
prefix_ void senf::console::Server::removeClient(Client & client)
{
- SENF_LOG(( "Disposing client " << & client ));
+ SENF_LOG_BLOCK(({
+ log << "Disposing client ";
+ try {
+ log << client.handle().peer();
+ }
+ catch (senf::SystemException ex) {
+ log << "(unknown)";
+ }
+ }));
// THIS DELETES THE CLIENT INSTANCE !!
clients_.erase(boost::intrusive_ptr<Client>(&client));
}
handle().write(data);
}
+prefix_ unsigned senf::console::detail::DumbClientReader::v_width()
+ const
+{
+ return 80;
+}
+
///////////////////////////////////////////////////////////////////////////
// senf::console::detail::NoninteractiveClientReader
handle().write(data);
}
+prefix_ unsigned senf::console::detail::NoninteractiveClientReader::v_width()
+ const
+{
+ return 80;
+}
+
prefix_ void
senf::console::detail::NoninteractiveClientReader::newData(int event)
{
// senf::console::Client
prefix_ senf::console::Client::Client(Server & server, ClientHandle handle)
- : out_t(boost::ref(*this)), senf::log::IOStreamTarget(out_t::member), server_ (server),
- handle_ (handle),
+ : out_t(boost::ref(*this)),
+ senf::log::IOStreamTarget("client-" + senf::str(handle.peer()), out_t::member),
+ server_ (server), handle_ (handle),
readevent_ ("senf::console::Client::interactive_check",
boost::bind(&Client::setNoninteractive,this),
handle, scheduler::FdEvent::EV_READ, false),
prefix_ std::string::size_type senf::console::Client::handleInput(std::string data,
bool incremental)
{
- if (data.empty() && ! incremental)
- data = lastCommand_;
- else
- lastCommand_ = data;
-
std::string::size_type n (data.size());
try {
reader_->enablePrompt();
}
-prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Client const & client)
+prefix_ unsigned senf::console::Client::getWidth(std::ostream & os, unsigned defaultWidth,
+ unsigned minWidth)
{
- typedef ClientSocketHandle< MakeSocketPolicy<
- INet4AddressingPolicy,ConnectedCommunicationPolicy>::policy > V4Socket;
- typedef ClientSocketHandle< MakeSocketPolicy<
- INet6AddressingPolicy,ConnectedCommunicationPolicy>::policy > V6Socket;
-
- try {
- 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);
- }
- catch (SystemException &) {
- os << "0.0.0.0:0";
+ unsigned rv (defaultWidth);
+ try {
+ rv = get(os).width();
}
-
- return os;
-}
-
-prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Client * client)
-{
- return os << *client;
+ catch (std::bad_cast &) {}
+ return rv < minWidth ? defaultWidth : rv;
}
///////////////////////////////////////////////////////////////////////////
{
Client & client (Client::get(os));
if (client.backtrace().empty())
- os << "(no backtrace)";
+ os << "(no backtrace)\n";
else
os << client.backtrace();
}