X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FServer.cc;h=4e37e68c403709ed6e4bbbf92b53716ccfeba385;hb=c70f7413515b513656f850f51a3cc2ea9d776a37;hp=6cd21d933d36e38f1f195a9cac615b68c2609924;hpb=d620e7ff9b68377ea20ca266c23cc3f05781868c;p=senf.git diff --git a/Console/Server.cc b/Console/Server.cc index 6cd21d9..4e37e68 100644 --- a/Console/Server.cc +++ b/Console/Server.cc @@ -104,7 +104,7 @@ prefix_ void senf::console::Server::removeClient(Client & client) prefix_ senf::console::Client::Client(ClientHandle handle, std::string const & name) : handle_ (handle), name_ (name), out_(::dup(handle.fd())) { - out_ << name_ << "# " << std::flush; + showPrompt(); ReadHelper::dispatch( handle_, 16384u, ReadUntil("\n"), senf::membind(&Client::clientData, this) ); } @@ -126,11 +126,6 @@ prefix_ void senf::console::Client::clientData(ReadHelper::ptr hel return; } -# warning fix Client::clientData implementation - // Remove the 'dup' needed here so we don't close the same fd twice (see Client constructor) - // Make output non-blocking - // Don't register a new ReadHelper every round - std::string data (tail_ + helper->data()); tail_ = helper->tail(); boost::trim(data); // Gets rid of superfluous \r or \n characters @@ -143,13 +138,24 @@ prefix_ void senf::console::Client::clientData(ReadHelper::ptr hel // THIS COMMITS SUICIDE. THE INSTANCE IS GONE AFTER stopClient RETURNS stopClient(); return; - } + } + catch (std::exception & ex) { + out_ << ex.what() << std::endl; + } + catch (...) { + out_ << "unidentified error (unknown exception thrown)" << std::endl; + } - out_ << name_ << "# " << std::flush; + showPrompt(); ReadHelper::dispatch( handle_, 16384u, ReadUntil("\n"), senf::membind(&Client::clientData, this) ); } +prefix_ void senf::console::Client::showPrompt() +{ + out_ << name_ << ":" << executor_.cwd().path() << "# " << std::flush; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "Server.mpp"