Exemplo n.º 1
0
void Connection::send(const Atlas::Objects::Root &obj)
{
    if ((_status != CONNECTED) && (_status != DISCONNECTING)) {
        error() << "called send on closed connection";
        return;
    }

    if (!_socket) {
        handleFailure("Connection::send: stream failed");
        hardDisconnect(true);
        return;
    }

#ifdef ATLAS_LOG
    std::stringstream debugStream;

    Atlas::Codecs::Bach debugCodec(debugStream, *this /*dummy*/);
    Atlas::Objects::ObjectsEncoder debugEncoder(debugCodec);
    debugEncoder.streamObjectsMessage(obj);
    debugStream << std::flush;

    std::cout << "sending:" << debugStream.str() << std::endl;
#endif

    _socket->getEncoder().streamObjectsMessage(obj);
    _socket->write();
}
Exemplo n.º 2
0
void PlayState::update()
{	

	if (clock.getElapsedTime().asMilliseconds() > 125 && !endOfGame)
	{
		if (doesFailureOccurs())
		{
			endOfGame = true;
			return;
		}

		setAppleFillColor();
		_snake->Move();


		if (_snake->GetHeadFloatRect() == _apple->getGlobalBounds())
		{
			_apple->setPosition(getRandomPosition()*(float)Game::APPLE_SIZE);
			_snake->AddBodyPart();
		}

		clock.restart();

	}

	else if (endOfGame)
		handleFailure();
}
Exemplo n.º 3
0
bool
TestMaster::compare(const char *file, uint32_t line,
                    const char *aName, const char *bName,
                    const char *opText,
                    const A &a, const B &b, const OP &op, bool fatal)
{
    if (op(a,b)) {
        ++threadState().passCnt;
        return true;
    }
    std::string str;
    str += aName;
    str += opText;
    str += bName;
    std::ostringstream lhs;
    std::ostringstream rhs;
    lhs << a;
    rhs << b;
    {
        vespalib::LockGuard guard(_lock);
        checkFailed(guard, file, line, str.c_str());
        printDiff(guard, str, file, line, lhs.str(), rhs.str());
        handleFailure(guard, fatal);
    }
    return false;
}
Exemplo n.º 4
0
// virtual
void LLTranslate::TranslationReceiver::completedRaw(
	U32 http_status,
	const std::string& reason,
	const LLChannelDescriptors& channels,
	const LLIOPipe::buffer_ptr_t& buffer)
{
	LLBufferStream istr(channels, buffer.get());
	std::stringstream strstrm;
	strstrm << istr.rdbuf();

	const std::string body = strstrm.str();
	std::string translation, detected_lang, err_msg;
	int status = http_status;
	LL_DEBUGS("Translate") << "HTTP status: " << status << " " << reason << LL_ENDL;
	LL_DEBUGS("Translate") << "Response body: " << body << LL_ENDL;
	if (mHandler.parseResponse(status, body, translation, detected_lang, err_msg))
	{
		// Fix up the response
		LLStringUtil::replaceString(translation, "&lt;", "<");
		LLStringUtil::replaceString(translation, "&gt;",">");
		LLStringUtil::replaceString(translation, "&quot;","\"");
		LLStringUtil::replaceString(translation, "&#39;","'");
		LLStringUtil::replaceString(translation, "&amp;","&");
		LLStringUtil::replaceString(translation, "&apos;","'");

		handleResponse(translation, detected_lang);
	}
	else
	{
		if (err_msg.empty())
		{
			err_msg = LLTrans::getString("TranslationResponseParseError");
		}

		llwarns << "Translation request failed: " << err_msg << llendl;
		handleFailure(status, err_msg);
	}
}
Exemplo n.º 5
0
void BaseConnection::stateChanged(StreamSocket::Status status)
{
    switch (status) {
    case StreamSocket::CONNECTING:
        setStatus(CONNECTING);
        break;
    case StreamSocket::CONNECTING_TIMEOUT:
        onConnectTimeout();
        break;
    case StreamSocket::CONNECTING_FAILED:
        handleFailure("Failed to connect to " + _host);
        hardDisconnect(true);
        break;
    case StreamSocket::NEGOTIATE:
        setStatus(NEGOTIATE);
        break;
    case StreamSocket::NEGOTIATE_FAILED:
        hardDisconnect(true);
        break;
    case StreamSocket::NEGOTIATE_TIMEOUT:
        onNegotiateTimeout();
        break;
    case StreamSocket::CONNECTED:
        setStatus(CONNECTED);
        onConnect();
        break;
    case StreamSocket::CONNECTION_FAILED:
        hardDisconnect(true);
        break;
    case StreamSocket::DISCONNECTING:
        setStatus(DISCONNECTING);
        break;
    default:
        break;
    }
}
Exemplo n.º 6
0
IcuTestErrorCode::~IcuTestErrorCode() {
    // Safe because our handleFailure() does not throw exceptions.
    if(isFailure()) { handleFailure(); }
}
Exemplo n.º 7
0
void ErrorCode::assertSuccess() const {
    if(isFailure()) {
        handleFailure();
    }
}
Exemplo n.º 8
0
QHotLoadImageBay::QHotLoadImageBay() : QObject(), dirHint(D_NEUTRAL) {
    qsrand(time(0));
    QObject::connect(&qiltp, SIGNAL(loadSuccess(QString,QImage)), this, SLOT(handleSuccess(QString,QImage)), Qt::DirectConnection);
    QObject::connect(&qiltp, SIGNAL(loadFailed(QString)), this, SLOT(handleFailure(QString)), Qt::DirectConnection);
    this->startTimer(50);
}
Exemplo n.º 9
0
U_NAMESPACE_BEGIN

IcuToolErrorCode::~IcuToolErrorCode() {
    // Safe because our handleFailure() does not throw exceptions.
    if(isFailure()) { handleFailure(); }
}
Exemplo n.º 10
0
void Connection::handleTimeout(const std::string& msg)
{
    handleFailure(msg); // all the same in the end
}