From 0ee6e6ee385c40222f6e403d451a961859827e2f Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Mon, 14 Apr 2008 23:46:45 +0200 Subject: [PATCH] Added g_nocatch support in UBSocket. --- src/Core/Socket/UBSocket.cpp | 70 ++++++++++++++++++++++++-------------------- src/Core/Socket/UBSocket.h | 1 + 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/Core/Socket/UBSocket.cpp b/src/Core/Socket/UBSocket.cpp index bdf21e8..95f0d1e 100644 --- a/src/Core/Socket/UBSocket.cpp +++ b/src/Core/Socket/UBSocket.cpp @@ -36,6 +36,8 @@ #include "Channel.h" #include "Managers.h" +extern bool g_nocatch; + UBSocket::UBSocket(ISocketHandler& h) : TcpSocket(h), m_prompt(), @@ -80,42 +82,53 @@ void UBSocket::OnAccept() } void UBSocket::OnLine(const std::string &line) -{ - bool popLast = false; - +{ SwitchEditors(); - Assert(!m_editors.empty()); + if(g_nocatch) + { + handleLine(line); + return; + } + try { - if(line.size() == 0) - { - m_editors.front()->OnEmptyLine(); - SendPrompt(); - return; - } - - if(m_editors.front()->supportPrefixes() && line.size()) - popLast = handlePrefixes(line); - - m_editors.front()->OnLine(line); - - if(popLast) - PopEditor(); - - SendPrompt(); + handleLine(line); } - catch(std::exception& e) + catch(std::exception& e) { + value_type accountid = 0; - if(m_account) - m_account->getID(); + + if(m_account) { + accountid = m_account->getID(); + } throw ExcecutionException(e, accountid, line); } +} + +void UBSocket::handleLine(const std::string& line) +{ + bool popLast = false; + + if(line.size() == 0) + { + m_editors.front()->OnEmptyLine(); + SendPrompt(); + return; + } - return; + if(m_editors.front()->supportPrefixes() && line.size()) + popLast = handlePrefixes(line); + + m_editors.front()->OnLine(line); + + if(popLast) + PopEditor(); + + SendPrompt(); } mud::AccountPtr UBSocket::GetAccount() const @@ -152,14 +165,7 @@ void UBSocket::SendPrompt() void UBSocket::SetEditor(Editor* edit, bool popLast) { - if(m_nexteditor) - { - Global::Get()->bug("UBSocket::SetEditor() was called while we are already waiting to switch to a next editor!\n"); - Send("Something went wrong, somehow you are switching to another editor while you were already doing just that!\n"); - Send("Closing your connection now.\n"); - SetCloseAndDelete(); - return; - } + Assert(!m_nexteditor); SetPrompt(); m_nexteditor = edit; diff --git a/src/Core/Socket/UBSocket.h b/src/Core/Socket/UBSocket.h index ae58d62..d368272 100644 --- a/src/Core/Socket/UBSocket.h +++ b/src/Core/Socket/UBSocket.h @@ -159,6 +159,7 @@ private: void SetPrompt(const std::string& prompt = ""); void SendPrompt(); bool handlePrefixes(const std::string& line); + void handleLine(const std::string& line); std::string m_prompt; /**< Current prompt. */ mud::AccountPtr m_account; /**< Current account. */ -- 2.11.4.GIT