void netAgent::prepareError(QAbstractSocket::SocketError socketError) { switch (socketError) { case QAbstractSocket::HostNotFoundError: emit error_signal(HOST_NOT_FOUND_ERR,QObject::trUtf8("Заданный сервер не найден или не доступен")); qDebug() <<Q_FUNC_INFO<<HOST_NOT_FOUND_ERR<< QObject::trUtf8("Заданный сервер не найден или не доступен"); break; case QAbstractSocket::ConnectionRefusedError: emit error_signal(CONNECTION_REFUSED_ERR,QObject::trUtf8("Соединение было закрыто удаленным сервером")); qDebug() <<Q_FUNC_INFO<<CONNECTION_REFUSED_ERR,QObject::trUtf8("Соединение было закрыто удаленным сервером"); break; } }
void netAgent::on_login(QString & hostname,int Port,QString &sid) { client_sid=sid; if (hostname.isEmpty()){ emit error_signal(HOSTNAME_EMPTY_ERR,QObject::trUtf8("Ошибка в файле конфигурации. Имя сервера не может быть пустым.")); qDebug() <<Q_FUNC_INFO<< HOSTNAME_EMPTY_ERR << QObject::trUtf8("Ошибка в файле конфигурации. Имя сервера не может быть пустым."); }else { if (Port<1024 or Port >65536){ emit error_signal (INVALID_PORT_RANGE_ERR,QObject::trUtf8("Ошибка в файле конфигурации. Порт %1 вне допустимого диапазона.").arg(Port)); qDebug() <<Q_FUNC_INFO<<INVALID_PORT_RANGE_ERR <<QObject::trUtf8("Ошибка в файле конфигурации. Порт %1 вне допустимого диапазона.").arg(Port); }else{ qDebug() <<Q_FUNC_INFO<<QString("Connect to %1:%2").arg(hostname).arg(Port,0,10); socket->connectToHost(hostname, Port); } } }
void lua_player::run_require_slot(std::string file) { try { QUrl url = player::create_url(file + ".lua", lua_path); activate_frame(file, url.toString ().toStdString ()); QObject::connect(current_activation_frame (), SIGNAL(execution_finished ()) , this, SLOT(require_finished ())); assert(pending_download_file == 0); pending_download_file = new player::url_file(url, this); if(!pending_download_file->local()) { QObject::connect(this, SIGNAL(download_lua_signal ()), this , SLOT(download_require ()), Qt::QueuedConnection); QObject::connect(pending_download_file, SIGNAL(download_finished_signal()), this , SLOT(download_lua())); QObject::connect(pending_download_file, SIGNAL(error_signal(std::string)), this , SLOT(download_error(std::string))); } else { QObject::connect(this, SIGNAL(download_lua_signal ()), this , SLOT(download_require ()), Qt::QueuedConnection); Q_EMIT download_lua_signal(); } } catch(std::exception const& e) { std::string error = "Error loading file "; error += lua_path; error += '/'; error += path; error += " with error: "; error += e.what(); ncl_window->error_occurred(error); } }
void lua_player::run_global_scope() { QObject::disconnect(this, SIGNAL (started ())); luaL_openlibs(L); luabind::open(L); luabind::module(L, "ghtv") [ luabind::class_<lua_player>("lua_player") ]; init_sandbox(); init_canvas(); init_event(); start_time = boost::posix_time::microsec_clock::universal_time(); QObject::connect(this, SIGNAL(resume_current_frame_signal (int)), this , SLOT(resume_current_frame (int)), Qt::QueuedConnection); QObject::connect(this, SIGNAL(run_require_signal (std::string)), this , SLOT(run_require_slot (std::string)), Qt::QueuedConnection); try { main_file_url = player::create_url(path, root_path); lua_path = main_file_url.path ().toStdString (); { std::string::reverse_iterator iterator = std::find(lua_path.rbegin(), lua_path.rend(), '/') , iterator_backslash = std::find(lua_path.rbegin(), lua_path.rend(), '\\'); iterator = (std::min)(iterator, iterator_backslash); if(iterator != lua_path.rend()) lua_path.erase(boost::prior(iterator.base()), lua_path.end()); else { std::string error_msg = "Couldn't create a absolute path from the path for the NCL file: "; error_msg += lua_path; ncl_window->error_occurred(error_msg); return; } } activate_frame(path, main_file_url.toString ().toStdString ()); QObject::connect(current_activation_frame (), SIGNAL(execution_finished ()) , this, SLOT(global_scope_finished ())); QObject::connect(this, SIGNAL(signal_all_execution_finished ()) , this, SLOT(try_unqueue_events ()), Qt::QueuedConnection); QObject::connect(this, SIGNAL(signal_try_unqueue_event ()) , this, SLOT(try_unqueue_event ()), Qt::QueuedConnection); assert(pending_download_file == 0); pending_download_file = new player::url_file(main_file_url, this); if(!pending_download_file->local()) { QObject::connect(this, SIGNAL(download_lua_signal ()), this , SLOT(download_global ()), Qt::QueuedConnection); QObject::connect(pending_download_file, SIGNAL(download_finished_signal()), this , SLOT(download_lua())); QObject::connect(pending_download_file, SIGNAL(error_signal(std::string)), this , SLOT(download_error(std::string))); } else { QObject::connect(this, SIGNAL(download_lua_signal ()), this , SLOT(download_global ()), Qt::QueuedConnection); Q_EMIT download_lua_signal(); } } catch(std::exception const& e) { std::string error = "Error loading file "; error += root_path; error += '/'; error += path; error += " with error: "; error += e.what(); ncl_window->error_occurred(error); } }