Exemplo n.º 1
0
void ChatSocket::OnLine(const std::string& line)
{
	switch (m_state)
	{
	case STATE_LOGIN:
		if (line.size())
		{
			m_name = line;
			m_state = STATE_PROMPT;
		}
		SendPrompt();
		break;
	case STATE_PROMPT:
		if (line.size())
		{
			if (line == "/who")
			{
				static_cast<ChatHandler&>(Handler()).Who(this);
			}
			else
			if (line == "/quit")
			{
				m_state = STATE_QUIT;
			}
			else
			{
				static_cast<ChatHandler&>(Handler()).Talk(m_name,line);
			}
		}
		SendPrompt();
		break;
	case STATE_QUIT:
		break;
	}
}
Exemplo n.º 2
0
void UBSocket::SwitchEditors()
{
    if(!m_popeditor && !m_nexteditor)
        return;

    if(m_popeditor && m_nexteditor)
    {
        Global::Get()->bug("UBSocket::SwitchEditors() was called, but we don't have both a new editor and we want to pop one?!");
        Send("Something went wrong, somehow you are switching to another editor but you're also deleting the top one?!\n");
        Send("Closing your connection now.\n");
        SetCloseAndDelete();
        return;
    }

    if(m_popeditor || m_popLast)
    {
        if(m_editors.empty()) // should never happen
        {
            Global::Get()->bug("UBSocket::SwitchEditors() was called, but we don't have a current editor?!");
            Send("Something went wrong, somehow you are switching to another editor but you don't have one set?!\n");
            Send("Closing your connection now.\n");
            SetCloseAndDelete();
            return;
        }

        delete m_editors.top();
        m_editors.pop();
        m_popeditor = false;
        m_popLast = false;
        SetPrompt(m_editors.top()->prompt());
    }

    if(m_nexteditor)
    {
        m_editors.push(m_nexteditor);
        m_nexteditor = NULL;
        SetPrompt(m_editors.top()->prompt());
    }

    m_editors.top()->OnFocus();

    if(m_nexteditor)
        SwitchEditors();
    else
        SendPrompt();
}
Exemplo n.º 3
0
void ChatSocket::OnAccept()
{
	Send("Welcome.\n");
	SendPrompt();
}