int AdminRFID::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: onConnect(); break; case 1: onReadyRead(); break; case 2: scanPorts(); break; default: ; } _id -= 3; } return _id; }
void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) { switch (msg->what()) { case kWhatConnect: onConnect(msg); break; case kWhatDisconnect: onDisconnect(msg); break; case kWhatCompleteConnection: onCompleteConnection(msg); break; case kWhatSendRequest: onSendRequest(msg); break; case kWhatReceiveResponse: onReceiveResponse(); break; case kWhatObserveBinaryData: { CHECK(msg->findMessage("reply", &mObserveBinaryMessage)); break; } #ifndef ANDROID_DEFAULT_CODE case kWhatTimeout: { unsigned long cseq; CHECK(msg->findInt32("cseq", (int32_t*)&cseq)); onTimeout(cseq); break; } case kWhatInjectPacket: { onInjectPacket(msg); break; } #endif // #ifndef ANDROID_DEFAULT_CODE default: TRESPASS(); break; } }
void IRC::connect(const string& host, const uint32_t port) { _server = host; _port = port; socket = new Socket(host,port); irc_thread::Handle irch; input_thread::Handle inh; output_thread::Handle outh; //OLD pthread stuff //pthread_create(&input_thread, NULL, input_thread_fun, (void*) this); //pthread_create(&output_thread, NULL, output_thread_fun, (void*) this); input_thread::Create((input_thread::Handler)input_thread_fun,(void*)this,&inh); output_thread::Create((output_thread::Handler)output_thread_fun,(void*)this,&outh); write("USER " + _login + " host server : " + _client); write("NICK " + _nick); connected = true; while(true) { string line = read(); if(line.length() > 0) { handle(line); //get first and second space, to find the code size_t s1 = line.find_first_of(" "); size_t s2 = line.find_first_of(" ", s1 + 1); if(s2 != string::npos) { if(line.compare(s1 + 1, 3, "004") == 0) { //connected! break; } else if(line.compare(s1 + 1, 3, "433") == 0) { //nickname taken! write("NICK " + _altnick); } } } } //pthread_create(&irc_thread, NULL, irc_thread_fun, (void*) this); irc_thread::Create((irc_thread::Handler)irc_thread_fun,(void*)this,&irch); onConnect(); }
void Client::controlEventHandler(ControlEvent* e) { switch(e->getId()) { case ID::NE_CONNECT: onConnect(boost::get<EndpointT>(e->getData())); break; case ID::NE_DISCONNECT: case ID::NE_SHUTDOWN: onDisconnect(0); break; default: warnlog << "Client: Can't handle event with ID: " << e->getId(); break; } }
bool BasicDeviceDriver::connect(void) { Counter<double> timer(1.0); try { trace("connecting..."); return onConnect(); } catch (...) { double delay = timer.getRemaining(); if (delay > 0.0) Delay::wait(delay); } return false; }
void FirehoseModel::reconnect() { if (m_nozzle.isEmpty()) return; // using WsAccessManager stopped after the HEADERS were returned // for some reason. We block signals to prevent recursively calling this // function if (m_socket) { disconnect( m_socket, 0, this, 0 ); // don't call onFinished() m_socket->deleteLater(); //safer, we had a crash } m_socket = new QTcpSocket( this ); connect( m_socket, SIGNAL(connected()), SLOT(onConnect()) ); connect( m_socket, SIGNAL(readyRead()), SLOT(onData()) ); connect( m_socket, SIGNAL(disconnected()), SLOT(onFinished()) ); m_socket->connectToHost( "firehose.last.fm", 80 ); }
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); }
void UDPConnection::connect(Socket::ConnectCallback callback){ auto udp_interface = std::static_pointer_cast<UDPInterface>(getParent()); conn_receive_timeout.expires_from_now(std::chrono::seconds(udp_interface->getInactivityTimeout())); conn_receive_timeout.async_wait([&](const boost::system::error_code& error){ if(error != boost::asio::error::operation_aborted){ connecting_callback((int)P2PError::timed_out, shared_from_this()); m_connected = false; }else{ connecting_callback(0, shared_from_this()); m_connected = true; onConnect(); sendKeepAlive(boost::system::error_code()); } }); send(UDP_CONNECT_MSG, [](int, std::shared_ptr<Connection>, std::string, int){}); }
Client::Client(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); tcpSocket = new QTcpSocket(this); promptConnect = new ConnectDialog(this); credentialsSent = false; ui.actionDisconnect->setDisabled(true); ui.actionReconnect->setDisabled(true); connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(getMessage())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); connect(tcpSocket, SIGNAL(connected()), this, SLOT(sendCredentials())); connect(tcpSocket, SIGNAL(connected()), this, SLOT(onConnect())); connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(onDisconnect())); connect(ui.userList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(whisperOnClick(QListWidgetItem*))); }
void Server::update() { if (!mNewSocket) { mNewSocket = std::make_unique<sf::TcpSocket>(); } if (mListener.accept(*mNewSocket) == sf::TcpListener::Done) { if (onConnect) onConnect(*this, mSocketId); mNewSocket->setBlocking(false); mSockets[mSocketId++].reset(mNewSocket.release()); } sf::Packet packet; for (auto it = mSockets.begin(); it != mSockets.end();) { auto& socket = *it->second; const auto status = socket.receive(packet); if (status == sf::TcpSocket::Done) { if (onReceive) onReceive(*this, it->first, packet); } else if (status == sf::TcpSocket::Disconnected) { if (onDisonnect) onDisonnect(*this, it->first); socket.disconnect(); mSockets.erase(it++); continue; } ++it; } }
MyClient::MyClient(int desc, MyServer *serv, QObject *parent) :QObject(parent) { //храниим указатель на объект-сервер _serv = serv; //клиент не прошел авторизацию _isAutched = false; _name = constNameUnknown; //размер принимаемого блока 0 _blockSize = 0; //создаем сокет _sok = new QTcpSocket(this); //устанавливаем дескриптор из incomingConnection() _sok->setSocketDescriptor(desc); //подключаем сигналы connect(_sok, SIGNAL(connected()), this, SLOT(onConnect())); connect(_sok, SIGNAL(disconnected()), this, SLOT(onDisconnect())); connect(_sok, SIGNAL(readyRead()), this, SLOT(onReadyRead())); connect(_sok, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onError(QAbstractSocket::SocketError))); qDebug() << "Client connected" << desc; }
int WebSocketImpl::connect_i(const std::string& ws_url) { if(!uri_.parse(ws_url)) { return false; } tcp_socket_.setReadCallback([this] (int err) { onReceive(err); }); tcp_socket_.setWriteCallback([this] (int err) { onSend(err); }); tcp_socket_.setErrorCallback([this] (int err) { onClose(err); }); setState(STATE_CONNECTING); std::string str_port = uri_.getPort(); uint16_t port = 80; uint32_t flag = 0; if(is_equal("wss", uri_.getScheme())) { port = 443; flag = FLAG_HAS_SSL; } if(!str_port.empty()) { port = atoi(str_port.c_str()); } return tcp_socket_.connect(uri_.getHost().c_str(), port, [this] (int err) { onConnect(err); }, flag); }
/** * Initializes the Phonemic app */ void Phonemic::init() { Events::neighborAdd.set(&Phonemic::onNeighborAdd, this); Events::neighborRemove.set(&Phonemic::onNeighborRemove, this); Events::cubeTouch.set(&Phonemic::onTouch, this); Events::cubeConnect.set(&Phonemic::onConnect, this); // Handle already-connected cubes int i = 0; for (CubeID cube : CubeSet::connected()) { onConnect(cube); cubes[cube].cid = cube; i++; } //level = gRandom.randint(0, LAST_LEVEL-1); level = 0; word = -1; nextWord(); }
void httpPoll_t :: start( void ) { if( ( idle == getState() ) && ( 0 != h_ ) ) { h_->setCallback( tcpHandler_t::connect_e, ::onConnect, this ); h_->setCallback( tcpHandler_t::disconnect_e, ::onDisconnect, this ); h_->setCallback( tcpHandler_t::dataAvail_e, ::onDataAvail, this ); h_->setCallback( tcpHandler_t::writeSpaceAvail_e, ::onWriteSpace, this ); h_->setCallback( tcpHandler_t::error_e, ::onError, this ); if( tcpHandler_t::connected == h_->getState() ) { onConnect( *h_ ); } else state_ = waitConnect ; } else fprintf( stderr, "Duplicate or invalid httpPoll_t::start(): %d\n", getState() ); }
bool HttpSession::start(const char *destHost, ProxyInfo &proxy) { this->destHost = destHost; bufSize = 0; if (sock >= 0) IcqSocket::closeSocket(sock); sock = IcqSocket::createSocket(SOCK_STREAM, this); sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; uname = proxy.username; passwd = proxy.passwd; const char *host = proxy.host.c_str(); if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) { hostent *he = gethostbyname(host); if (!he) goto failed; addr.sin_addr = *(in_addr *) he->h_addr; } addr.sin_port = htons(proxy.port); status = HTTP_STATUS_CONNECT; if (connect(sock, (sockaddr *) &addr, sizeof(addr)) == 0) onConnect(true); else if (IcqSocket::getSocketError() != EINPROGRESS) goto failed; return true; failed: close(sock); sock = -1; listener->sessionFinished(false); return false; }
ServerBrowser::ServerBrowser(QWidget *parent) : QMainWindow(parent), ui(new Ui::ServerBrowser) { ui->setupUi(this); QStringList labels; labels << "Server Name" << "Players" << "Mode" << "Map" << "IP/Port"; ui->twServers->setHeaderLabels(labels); ui->twServers->setColumnWidth(0, 200); ui->twServers->setColumnWidth(1, 70); ui->twServers->setColumnWidth(2, 170); ui->twServers->setColumnWidth(3, 170); ui->twServers->setColumnWidth(4, 170); ui->twServers->setParent(ui->wServers); ui->btnConnect2->setParent(ui->wServers); ui->btnRefresh->setParent(ui->wServers); ui->btnAddFav->setParent(ui->wServers); m_Socket = NULL; MasterListStartup(); http = new QHttp(MASTERLIST_HOST, 80); selected = 0; QSettings settings("Vice-Players", "Browser"); ui->leIP->setText(settings.value("IP", "127.0.0.1").toString()); ui->leNick->setText(settings.value("Nick", "Player").toString()); ui->lePort->setText(settings.value("Port", "5192").toString()); connect(http, SIGNAL(done(bool)), this, SLOT(httpDone())); connect(ui->twServers, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(onDoubleClick(QTreeWidgetItem*,int)) ); connect(ui->btnRefresh, SIGNAL(released()), this, SLOT(Refresh())); connect(ui->btnConnect, SIGNAL(released()), this, SLOT(onConnect())); connect(ui->btnAddFav, SIGNAL(clicked()), this, SLOT(AddFavourite())); Refresh(); }
//------------------------------------------------------------------------------ void WESplClient::setup() { // do the setup stuffs here if(fOwner.getDebugLvl()) cout << "setting connection to moduleid " << getPmId() << endl; char buff[32]; snprintf(buff, sizeof(buff), "pm%u_WriteEngineServer", getPmId()); fServer = buff; fClnt.reset(new MessageQueueClient(fServer)); if(fOwner.getDebugLvl()) cout << "WEServer : " << fServer << " " << fClnt->addr2String() <<endl; try { if (fClnt->connect()) { onConnect(); startClientThread(); } else { throw runtime_error("Connection refused"); } } catch (std::exception& ex) { cerr << "Could not connect to " << fServer << ": " << ex.what() << endl; throw runtime_error("Problem in connecting to PM"); } catch (...) { cerr << "Could not connect to " << fServer << endl; throw runtime_error("Problem in connecting to PM"); } }
void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) { switch (msg->what()) { case kWhatConnect: onConnect(msg); break; case kWhatDisconnect: onDisconnect(msg); break; case kWhatReconnect: onReconnect(msg); break; case kWhatCompleteConnection: onCompleteConnection(msg); break; case kWhatSendRequest: onSendRequest(msg); break; case kWhatReceiveResponse: onReceiveResponse(); break; case kWhatObserveBinaryData: { CHECK(msg->findMessage("reply", &mObserveBinaryMessage)); break; } default: TRESPASS(); break; } }
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; } }
QtUdpSocketPlugin::QtUdpSocketPlugin() : _socket(nullptr), _helperReceiveCallback(), _checkerReceiveCallback(), _messageCounter(0), _conditionLock(), _conditionVariable(), _targetHost(), _targetPort(0) { QObject::connect(this, SIGNAL(doListen(quint16)), this, SLOT(onListen(quint16))); QObject::connect(this, SIGNAL(doConnect(QString, quint16)), this, SLOT(onConnect(QString, quint16))); QObject::connect(this, SIGNAL(doSendMessage(QString)), this, SLOT(onSendMessage(QString))); QObject::connect(this, SIGNAL(doDisconnect()), this, SLOT(onDisconnect())); }
void TcpSession::onReconnect( boost::shared_ptr<boost::asio::deadline_timer> t ) { onConnect(); }
void TcpSession::reconnect() { onConnect(); }
//----------------------------------------------------------------------------- // Function: BusIfPortmapTab::BusIfPortmapTab() //----------------------------------------------------------------------------- BusIfPortmapTab::BusIfPortmapTab( LibraryInterface* libHandler, QSharedPointer<Component> component, BusInterface* busif, QWidget* parent ): QWidget(parent), busif_(busif), component_(component), libHandler_(libHandler), model_(busif, component, libHandler, this), view_(this), logicalView_(this), logicalModel_(libHandler, &model_, this), mappingLabel_(tr("Bit-field mapping"),this), mappingView_(component, this), mappingProxy_(this), mappingModel_(busif, component, libHandler, this), physicalView_(this), physProxy_(component, this), physModel_(component, &model_, this), cleanButton_(QIcon(":/icons/common/graphics/cleanup.png"), tr("Clean up"), this), connectButton_(QIcon(":/icons/common/graphics/connect.png"), tr("Connect"), this), showAllButton_(tr("Show all ports in component"), this), showHideMappingButton_(tr("Show bit-field mapping"),this), nameFilterEditor_(new QLineEdit(this)), inButton_(QIcon(":/icons/common/graphics/control-180.png"), "", this), outButton_(QIcon(":/icons/common/graphics/control.png"), "", this), hideConnectedBox_(tr("Hide connected ports"), this), portSet_() { view_.setModel(&model_); view_.setItemDelegate(new PortMapsDelegate(this)); mappingView_.setDragDropMode(QAbstractItemView::DropOnly); mappingView_.setAcceptDrops(true); mappingProxy_.setSourceModel(&mappingModel_); mappingView_.setModel(&mappingProxy_); mappingLabel_.hide(); mappingView_.hide(); // Set view to be sortable. mappingProxy_.setSortCaseSensitivity(Qt::CaseInsensitive); mappingView_.setSortingEnabled(true); mappingView_.sortByColumn(BitMappingModel::INDEX, Qt::AscendingOrder); hideConnectedBox_.setCheckState(Qt::Checked); // Set the sources for views. logicalView_.setModel(&logicalModel_); physProxy_.setSourceModel(&physModel_); physicalView_.setModel(&physProxy_); // Remove the ports from the port lists that are already mapped. logicalModel_.removePorts(model_.logicalPorts()); setupLayout(); // By default, show all button is not visible, but setting physical ports sets visible. showAllButton_.setVisible(false); inButton_.setToolTip(tr("Filter ports by direction in")); outButton_.setToolTip(tr("Filter ports by direction out")); nameFilterEditor_->setToolTip(tr("Filter ports by name")); setTabOrder(&inButton_, &outButton_); setTabOrder(&outButton_, nameFilterEditor_); setTabOrder(nameFilterEditor_, &physicalView_); // Connect signals from model. connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(&model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(&model_, SIGNAL(errorMessage(const QString&)), this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(noticeMessage(const QString&)), this, SIGNAL(noticeMessage(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(logicalRemoved(const QString&)), &logicalModel_, SLOT(addPort(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(logicalRemoved(const QString&)), &mappingModel_, SLOT(onRemoveMapping(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(logicalRestored(const QString&)), &logicalModel_, SLOT(addPort(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(logicalRestored(const QString&)), &logicalView_, SLOT(onPortRestored(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(physicalRemoved(const QString&)), &physModel_, SLOT(addPort(const QString&)), Qt::UniqueConnection); connect(&model_, SIGNAL(physicalRemoved(const QString&)), &physProxy_, SLOT(onPortDisconnected(const QString&)), Qt::UniqueConnection); // Connect signals from logical view. connect(&logicalView_, SIGNAL(removeItem(const QModelIndex&)), &logicalModel_, SLOT(removeItem(const QModelIndex&)), Qt::UniqueConnection); connect(&logicalView_, SIGNAL(removeItems(const QModelIndexList&)), &logicalModel_, SLOT(removeItems(const QModelIndexList&)), Qt::UniqueConnection); connect(&logicalView_, SIGNAL(makeConnection(const QStringList&, const QStringList&)), this, SLOT(onMakeConnections(const QStringList&, const QStringList&)), Qt::UniqueConnection); connect(&logicalView_, SIGNAL(moveItems(const QStringList&, const QModelIndex&)), &logicalModel_, SLOT(onMoveItems(const QStringList&, const QModelIndex&)), Qt::UniqueConnection); connect(&logicalView_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onLogicalChanged(const QModelIndex&)), Qt::UniqueConnection); // Connect signals from physical view. connect(&physicalView_, SIGNAL(makeConnection(const QStringList&, const QStringList&)), this, SLOT(onMakeConnections(const QStringList&, const QStringList&)), Qt::UniqueConnection); connect(&physicalView_, SIGNAL(moveItems(const QStringList&, const QModelIndex&)), &physModel_, SLOT(onMoveItems(const QStringList&, const QModelIndex&)), Qt::UniqueConnection); // Connect signals from logical model. connect(&logicalModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(&logicalModel_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection); // Connect signal from physical model. connect(&physModel_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(&physModel_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection); // Connect signals from physical port filters. connect(nameFilterEditor_, SIGNAL(textChanged(const QString&)), &physProxy_, SLOT(setFilterPortName(const QString&)), Qt::UniqueConnection); connect(nameFilterEditor_, SIGNAL(textChanged(const QString&)), &physicalView_, SLOT(onFilterNameChanged(const QString&)), Qt::UniqueConnection); connect(&inButton_, SIGNAL(clicked(bool)), &physProxy_, SLOT(setFilterInDirection(bool)), Qt::UniqueConnection); connect(&outButton_, SIGNAL(clicked(bool)), &physProxy_, SLOT(setFilterOutDirection(bool)), Qt::UniqueConnection); // Connect signals from bit-field mapping model. connect(&mappingModel_, SIGNAL(errorMessage(const QString&)), this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection); connect(&mappingModel_, SIGNAL(logicalPortSet(const QString&)), &mappingView_, SLOT(onLogicalPortChanged(const QString&)), Qt::UniqueConnection); // Connect signals from toolbar buttons. connect(&cleanButton_, SIGNAL(clicked(bool)), this, SLOT(onRefresh()), Qt::UniqueConnection); connect(&connectButton_, SIGNAL(clicked(bool)), this, SLOT(onConnect()), Qt::UniqueConnection); connect(&showHideMappingButton_, SIGNAL(clicked(bool)), this, SLOT(toggleMappingVisibility()), Qt::UniqueConnection); connect(&hideConnectedBox_, SIGNAL(toggled(bool)), &physProxy_, SLOT(setFilterHideConnected(bool)), Qt::UniqueConnection); connect(&showAllButton_, SIGNAL(clicked(bool)), this, SLOT(onShowAll()), Qt::UniqueConnection); }
void CTcpConnection::Start() { onConnect(); // m_oSocket.async_receive(); }
void UDPConnection::receivedConnect() { m_connected = true; onConnect(); sendKeepAlive(boost::system::error_code()); }
/*! \brief Connect all modules in the application to their ports using connections list*/ void ApplicationViewWidget::connectConnectionSet() { selectAllConnections(true); onConnect(); }
void test_onConnect() { onConnect(); }
tstMainWindow::tstMainWindow(QWidget *parent) : QMainWindow(parent) { d = new tstMainWindowPrivate; d->controller = new dtkDistributedController; d->status_model = new dtkDistributedControllerStatusModel(this); d->status_model->setController(d->controller); d->status_view = new dtkDistributedControllerStatusView(this); d->status_view->setModel(d->status_model); d->host_address = new QLineEdit("dtk://nef-devel.inria.fr:9999", this); d->host_address->setAttribute(Qt::WA_MacShowFocusRect, false); d->host_button = new QPushButton("Connect", this); d->host_button->setAttribute(Qt::WA_MacShowFocusRect, false); d->host_button->setFixedWidth(200); d->submit_nodes = new QSpinBox(this); d->submit_nodes->setMaximum(100); d->submit_nodes->setValue(2); d->submit_cores = new QSpinBox(this); d->submit_cores->setMaximum(48); d->submit_cores->setValue(8); d->submit_value = new QSpinBox(this); d->submit_value->setMaximum(100000); d->submit_value->setValue(100000); d->submit_button = new QPushButton("Submit", this); d->submit_button->setAttribute(Qt::WA_MacShowFocusRect, false); d->submit_button->setFixedWidth(200); QHBoxLayout *host_layout = new QHBoxLayout; host_layout->addWidget(d->host_address); host_layout->addWidget(d->host_button); QHBoxLayout *submit_layout = new QHBoxLayout; submit_layout->addWidget(d->submit_nodes); submit_layout->addWidget(d->submit_cores); submit_layout->addWidget(d->submit_value); submit_layout->addWidget(d->submit_button); QWidget *host_widget = new QWidget(this); host_widget->setLayout(host_layout); QWidget *submit_widget = new QWidget(this); submit_widget->setLayout(submit_layout); QWidget *central = new QWidget(this); QVBoxLayout *central_layout = new QVBoxLayout(central); central_layout->setContentsMargins(0, 0, 0, 0); central_layout->setSpacing(0); central_layout->addWidget(host_widget); central_layout->addWidget(d->status_view); central_layout->addWidget(submit_widget); this->setCentralWidget(central); this->setUnifiedTitleAndToolBarOnMac(true); this->setWindowTitle("dtkDistributedTutorial - Step #6"); connect(d->host_button, SIGNAL(clicked()), this, SLOT(onConnect())); connect(d->submit_button, SIGNAL(clicked()), this, SLOT(onSubmit())); connect(d->controller, SIGNAL(dataPosted(const QByteArray&)), this, SLOT(onDataPosted(const QByteArray&))); connect(d->controller, SIGNAL(jobStarted(QString)), this, SLOT(onJobStarted(QString))); }
void ServerHost::doTick() { // Get a packet from either the server or the client for (RakNet::Packet* p = m_server->Receive(); p; m_server->DeallocatePacket(p), p=m_server->Receive()) { // We got a packet, get the identifier with our handy function unsigned char packetIdentifier = GetPacketIdentifier(p); // Check if this is a network message packet switch (packetIdentifier) { case ID_DISCONNECTION_NOTIFICATION: // Connection lost normally printf("ID_DISCONNECTION_NOTIFICATION\n"); m_peer.initServer(m_server,p->guid,p->systemAddress); onDisconnect(&m_peer); break; case ID_ALREADY_CONNECTED: // Connection lost normally printf("ID_ALREADY_CONNECTED with guid %" PRINTF_64_BIT_MODIFIER "u\n", p->guid); break; case ID_INCOMPATIBLE_PROTOCOL_VERSION: printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n"); break; case ID_CONNECTION_BANNED: // Banned from this server printf("We are banned from this server.\n"); break; case ID_CONNECTION_ATTEMPT_FAILED: printf("Connection attempt failed\n"); break; case ID_NO_FREE_INCOMING_CONNECTIONS: // Sorry, the server is full. I don't do anything here but // A real app should tell the user printf("ID_NO_FREE_INCOMING_CONNECTIONS\n"); break; case ID_INVALID_PASSWORD: printf("ID_INVALID_PASSWORD\n"); break; case ID_CONNECTION_LOST: // Couldn't deliver a reliable packet - i.e. the other system was abnormally // terminated printf("ID_CONNECTION_LOST\n"); m_peer.initServer(m_server,p->guid,p->systemAddress); onDisconnect(&m_peer); break; case ID_NEW_INCOMING_CONNECTION: // This tells the client they have connected m_peer.initServer(m_server,p->guid,p->systemAddress); onConnect(&m_peer); break; case ID_CONNECTED_PING: case ID_UNCONNECTED_PING: printf("Ping from %s\n", p->systemAddress.ToString(true)); break; case ID_USER_PACKET_ENUM: { RakNet::RakString rs; RakNet::BitStream bsIn(p->data,p->length,false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(rs); m_peer.initServer(m_server,p->guid,p->systemAddress); onReceive(&m_peer,rs.C_String(),rs.GetLength()); } break; default: break; } } }
ContestantApp::ContestantApp ( QWidget* parent ) : QMainWindow ( parent ), m_dlg ( new Ui::contestant_app_dlg ), DISCONNECT_INFORMATION ( tr ( "There will be a penalty for disconnecting." ) ), DISCONNECT_QUESTION ( tr ( "Are you sure you want to exit the program?" ) ), UNAUTH_TEXT ( tr ( "Unable to obtain authorization." ) ), UNAUTH_INFORMATION ( tr ( "Username or password may be incorrect." ) ) { m_login_dlg = new Ui::login_dlg; m_welcome_dlg = new Ui::welcome_dlg; m_elims_dlg = new Ui::elims_dlg; m_semifinals_dlg = new Ui::semifinals_dlg; m_finalsChoice_dlg = new Ui::finalsChoice_dlg; m_finalsIdent_dlg = new Ui::finalsIdent_dlg; m_summary_dlg = new Ui::summary_dlg; m_ending_dlg = new Ui::ending_dlg; m_dlg->setupUi( this ); QPixmap logo("resources/logo.png"); m_dlg->cerb_logo_lbl->setPixmap(logo); //this->hide(); m_welcome_w = new QDialog( this ); m_welcome_dlg->setupUi( m_welcome_w ); m_welcome_w->hide(); m_elims_w = new QDialog( this ); m_elims_dlg->setupUi( m_elims_w ); m_elims_w->hide(); m_semifinals_w = new QDialog( this ); m_semifinals_dlg->setupUi( m_semifinals_w ); m_semifinals_w->hide(); m_finalsChoice_w = new QDialog( this ); m_finalsChoice_dlg->setupUi( m_finalsChoice_w ); m_finalsChoice_w->hide(); m_finalsIdent_w = new QDialog( this ); m_finalsIdent_dlg->setupUi( m_finalsIdent_w ); m_finalsIdent_w->hide(); m_summary_w = new QDialog( this ); m_summary_dlg->setupUi( m_summary_w ); m_summary_w->hide(); m_ending_w = new QDialog( this ); m_ending_dlg->setupUi( m_ending_w ); m_ending_w->hide(); m_login_w = new QDialog( this ); m_login_dlg->setupUi( m_login_w ); m_login_w->show(); m_network = new ContestantNetwork ( this ); timer = new QTimer( this ); connect( m_network, SIGNAL ( onConnect() ), this, SLOT ( onConnect() ) ); connect( m_network, SIGNAL ( onDisconnect() ), this, SLOT ( onDisconnect() ) ); connect( m_network, SIGNAL ( onAuthenticate ( bool ) ), this, SLOT ( onAuthenticate ( bool ) ) ); connect( m_network, SIGNAL ( onContestStateChange ( int, CONTEST_STATUS ) ), this, SLOT ( onContestStateChange ( int, CONTEST_STATUS ) ) ); connect( m_network, SIGNAL ( onQuestionStateChange ( ushort, ushort, QUESTION_STATUS ) ), this, SLOT ( onQuestionStateChange ( ushort, ushort, QUESTION_STATUS ) ) ); connect( m_network, SIGNAL ( onContestTime ( ushort ) ), this, SLOT ( onContestTime ( ushort ) ) ); connect( m_network, SIGNAL ( onQData ( QString ) ), this, SLOT ( onQData ( QString ) ) ); connect( m_network, SIGNAL ( onAData ( bool ) ), this, SLOT ( onAData ( bool ) ) ); connect( m_network, SIGNAL ( onContestError ( ERROR_MESSAGES ) ), this, SLOT ( onContestError ( ERROR_MESSAGES ) ) ); connect( m_network, SIGNAL(onError(QString)), this, SLOT ( onError ( QString ) ) ); // connections for the login dialog connect( m_login_dlg->login_btn, SIGNAL ( clicked() ), this, SLOT ( login() ) ); connect( m_login_dlg->exit_btn, SIGNAL ( clicked() ), this, SLOT ( exit() ) ); // connections for the welcome dialog connect( m_welcome_dlg->start_btn, SIGNAL ( clicked() ), this, SLOT ( welcomeStart() ) ); // connections for the elims and semis dialog connect( m_elims_dlg->prev_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiPrev() ) ); connect( m_elims_dlg->next_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiNext() ) ); connect( m_semifinals_dlg->prev_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiPrev() ) ); connect( m_semifinals_dlg->next_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiNext() ) ); // connections for summary dialog connect( m_summary_dlg->review_btn, SIGNAL( clicked() ), this, SLOT( review() ) ); connect( m_summary_dlg->submit_btn, SIGNAL( clicked() ), this, SLOT( submit() ) ); // connections for finals dialog connect( m_finalsChoice_dlg->submit_btn, SIGNAL( clicked() ), this, SLOT( finalsSubmit() ) ); connect( m_finalsIdent_dlg->submit_btn, SIGNAL( clicked() ), this, SLOT( finalsSubmit() ) ); // connections for ending dialog connect( m_ending_dlg->exit_btn, SIGNAL( clicked() ), this, SLOT( exit() ) ); // slot for timer connect( timer, SIGNAL( timeout() ), this, SLOT( updateTimer() ) ); // Get the client configuration from XmlUtil qCount = 0; time = 0; status = CONTEST_STOPPED; qStatus = QUESTION_STOPPED; connected = false; loggedIn = false; closing = false; }