Exemplo n.º 1
0
void BooRedisAsync::onError(const boost::system::error_code &error)
{
    if (error == boost::asio::error::operation_aborted)
        return;

    if (error!=boost::system::error_code()) //If not decode error
        onLogMessage("Connection to Redis " + endpointToString(m_endpointIterator) + " failed: "
                     + error.message(),LOG_LEVEL_ERR);

    m_writeInProgress = false;
    m_connected = false;
    m_connectTimer->cancel();

    try {
        closeSocket(); //close socket and cleanup
    } catch (...) {}

    m_decoder.reset();

    onDisconnect();

    boost::asio::ip::tcp::resolver::iterator it = getEndpointIterator();
    if (!onceConnected() && !isLastEndpoint(it)) { //try another address
        setEndpointIterator(++it); //switch to the next endpoint
        onLogMessage("Trying next Redis address: " + endpointToString(it),LOG_LEVEL_DEBUG);
    } else
        sleep(1);

    onLogMessage("Reconnecting to Redis " + endpointToString(it),LOG_LEVEL_INFO);

    connect(it);
}
Exemplo n.º 2
0
GLWidget::GLWidget(QWidget *parent)
     : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    m_resolutionMode = RenderPropertiesUI::RM_MATCH_WINDOW;
	m_resolutionLongestAxis = 1024;
	m_activeTool = NULL;
	m_activeUserDialogs = 0U;

    connect(&m_logger, SIGNAL(logMessage(QString)), this, SLOT(onLogMessage(QString)));
}
Exemplo n.º 3
0
void BooRedisAsync::connectComplete(const boost::system::error_code& error)
{
    if (!error)
    {
        m_connectTimer->cancel();
        readStart();
        m_onceConnected = true;
        m_connected = true;

        onLogMessage("Successfully connected to Redis " + endpointToString(getEndpointIterator()),LOG_LEVEL_INFO);
        onConnect();

        if (!m_writeInProgress && !m_writeBuffer.empty())
            writeStart();
    }
    else
        onError(error);
}
Exemplo n.º 4
0
void BooRedisAsync::readComplete(const boost::system::error_code &error, size_t bytesTransferred)
{
    if (!error)
    {
        std::vector<RedisMessage> result;
        BooRedisDecoder::DecodeResult res = m_decoder.decode(m_readBuffer,bytesTransferred,result);

        for (std::vector<RedisMessage>::iterator it=result.begin();it!=result.end();++it)
            onRedisMessage(*it);

        if (res != BooRedisDecoder::DecodeError)
            readStart();
        else {
            onLogMessage("Error decoding redis message. Reconnecting",LOG_LEVEL_ERR);
            onError(boost::system::error_code());
        }
    }
    else
        onError(error);
}
Exemplo n.º 5
0
void BooRedisAsync::connect(const char *address, int port, int timeout_msec)
{
    if (m_connected)
        disconnect();

    boost::asio::ip::tcp::resolver resolver(*m_ioService);
    char aport[8];
    sprintf(aport,"%d",port); //resolver::query accepts string as second parameter

    boost::asio::ip::tcp::resolver::query query(address, aport);
    boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);

    onLogMessage(std::string("Connecting to Redis ") + address + ":" + aport);

    m_connectionTimeout = boost::posix_time::milliseconds(timeout_msec);

    connectStart(iterator);

    if (m_ownIoService && boost::this_thread::get_id() != m_thread.get_id())
        m_thread = boost::thread(boost::bind(&boost::asio::io_service::run, m_ioService));
}
Exemplo n.º 6
0
  void LogListenerImpl::log(const LogMessage& msg)
  {
    DEBUG("LL:log: " << msg.message);
    if (msg.level > logLevel.get())
      return;

    // Check filters.
    // map ordering will give us more generic globbing filter first
    // so we must not stop on first negative filter, but go on
    // to see if a positive filter overrides it@
    bool pass = true;
    {
      boost::mutex::scoped_lock filtersLock(_filtersMutex);

      for (FilterMap::iterator it = _filters.begin(); it != _filters.end(); ++it)
      {
        const std::string& f = it->first;
        if (f == msg.category ||
            (f.find('*') != f.npos && qi::os::fnmatch(f, msg.category)))
        {
          pass = msg.level <= it->second;
        }
      }
    }

    DEBUG("LL:log filter " << pass);
    if (pass)
    {
      onLogMessage(msg);

      std::vector<qi::LogMessage> msgs;
      msgs.push_back(msg);
      onLogMessages(msgs);
      onLogMessagesWithBacklog(msgs);
    }
    DEBUG("LL:log done");
  }
Exemplo n.º 7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
	qRegisterMetaType<Material::SerializedData>("SerializedMaterialData");

	// GLWidget
	connect(this, SIGNAL(beginUserInteraction(void)), 
			ui->glWidget, SLOT(onBeginUserInteraction(void)));
	connect(this, SIGNAL(endUserInteraction(void)), 
			ui->glWidget, SLOT(onEndUserInteraction(void)));
	connect(ui->glWidget, SIGNAL(materialCreated(Material::SerializedData&)),
			this, SLOT(onMaterialCreated(Material::SerializedData&)));
	connect(this, SIGNAL(materialColorChanged(unsigned int, QColor)),
			ui->glWidget, SLOT(onMaterialColorChanged(unsigned int, QColor)));
	connect(this, SIGNAL(materialValueChanged(unsigned int, float)),
			ui->glWidget, SLOT(onMaterialValueChanged(unsigned int, float)));

    // Camera properties widget

    connect(ui->cameraProperties, SIGNAL(lensModelChanged(int)),
            ui->glWidget, SLOT(cameraLensModelChanged(int)));
    connect(ui->cameraProperties, SIGNAL(lensRadiusChanged(QString)),
            ui->glWidget, SLOT(cameraFStopChanged(QString)));
    connect(ui->cameraProperties, SIGNAL(focalLengthChanged(QString)),
            ui->glWidget, SLOT(cameraFocalLengthChanged(QString)));
    connect(ui->cameraProperties, SIGNAL(cameraControllerChanged(QString)),
            ui->glWidget, SLOT(cameraControllerChanged(QString)));

    // Render properties widget

    connect(ui->renderProperties, SIGNAL(pathtracerMaxSamplesChanged(int)),
            ui->glWidget, SLOT(onPathtracerMaxSamplesChanged(int)));
    connect(ui->renderProperties, SIGNAL(pathtracerMaxPathBouncesChanged(int)),
            ui->glWidget, SLOT(onPathtracerMaxPathBouncesChanged(int)));
    connect(ui->renderProperties, SIGNAL(resolutionSettingsChanged(void)),
            this, SLOT(onResolutionSettingsChanged(void)));
    connect(ui->renderProperties, SIGNAL(wireframeOpacityChanged(int)),
            ui->glWidget, SLOT(onWireframeOpacityChanged(int)));
    connect(ui->renderProperties, SIGNAL(wireframeThicknessChanged(int)),
            ui->glWidget, SLOT(onWireframeThicknessChanged(int)));
    connect(ui->renderProperties, SIGNAL(backgroundColorChangedConstant(QColor)),
            ui->glWidget, SLOT(onBackgroundColorChangedConstant(QColor)));
    connect(ui->renderProperties, SIGNAL(backgroundColorChangedGradientFrom(QColor)),
            ui->glWidget, SLOT(onBackgroundColorChangedGradientFrom(QColor)));
    connect(ui->renderProperties, SIGNAL(backgroundColorChangedGradientTo(QColor)),
            ui->glWidget, SLOT(onBackgroundColorChangedGradientTo(QColor)));
    connect(ui->renderProperties, SIGNAL(backgroundColorChangedImage(QString)),
            ui->glWidget, SLOT(onBackgroundColorChangedImage(QString)));
    connect(ui->renderProperties, SIGNAL(backgroundImageRotationChanged(int)),
            ui->glWidget, SLOT(onBackgroundImageRotationChanged(int)));
	connect(ui->renderProperties, SIGNAL(beginUserInteraction(void)), 
			ui->glWidget, SLOT(onBeginUserInteraction(void)));
	connect(ui->renderProperties, SIGNAL(endUserInteraction(void)), 
			ui->glWidget, SLOT(onEndUserInteraction(void)));


	// log window
    connect(ui->glWidget, SIGNAL(logMessage(QString)),
            ui->logWindow, SLOT(onLogMessage(QString)));

	ui->renderProperties->setBackground(QColor(192, 192, 192));
	ui->renderProperties->setBackground(QColor(153, 187, 201), QColor(77, 64, 50));
}