Example #1
0
Minecraft::Minecraft(ServerEntry *serverEntry) : Game(serverEntry)
{
    con = new MinecraftConnection(this);
    con->hostConnect(serverEntry->host, serverEntry->port);

    connect(con, SIGNAL(onConnected()), this, SLOT(onConnected()));
}
Example #2
0
void TcpClient::handleEvent(short events)
{
	if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT))
	{
		bufferevent_disable(_bev, EV_READ | EV_WRITE);
		evutil_closesocket(getSocket());
		_isConnected = false;
		onDisconnected();
		bufferevent_free(_bev);
		_bev = NULL;
		return;
	}

	if (events & BEV_EVENT_CONNECTED)
	{
		int socketError = EVUTIL_SOCKET_ERROR();
		if ((socketError != ECONNREFUSED) && (socketError != ETIMEDOUT))
		{
			_isConnected = true;
			onConnected(0);
		}
		else
		{
			onConnected(socketError);
		}
	}
}
Example #3
0
EventsWidget::EventsWidget(FrostbiteConnection *connection, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::EventsWidget),
    m_connection(connection),
    m_commandHandler(dynamic_cast<BF4CommandHandler *>(connection->getCommandHandler()))
{
    ui->setupUi(this);

    /* Connection */
    connect(m_connection, SIGNAL(onConnected()), this, SLOT(onConnected()));
    connect(m_connection, SIGNAL(onDisconnected()), this, SLOT(onDisconnected()));

    /* Events */
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerAuthenticatedEvent,       this, &EventsWidget::onPlayerAuthenticatedEvent);
    connect(m_commandHandler, &BF4CommandHandler::onPlayerDisconnectEvent,                 this, &EventsWidget::onPlayerDisconnectEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerJoinEvent,                this, &EventsWidget::onPlayerJoinEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerLeaveEvent,               this, &EventsWidget::onPlayerLeaveEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerSpawnEvent,               this, &EventsWidget::onPlayerSpawnEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerKillEvent,                this, &EventsWidget::onPlayerKillEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerChatEvent,                this, &EventsWidget::onPlayerChatEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerSquadChangeEvent,         this, &EventsWidget::onPlayerSquadChangeEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onPlayerTeamChangeEvent,          this, &EventsWidget::onPlayerTeamChangeEvent);
    connect(m_commandHandler, &BF4CommandHandler::onServerMaxPlayerCountChangeEvent,       this, &EventsWidget::onServerMaxPlayerCountChangeEvent);
    connect(m_commandHandler, &BF4CommandHandler::onServerLevelLoadedEvent,                this, &EventsWidget::onServerLevelLoadedEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onServerRoundOverEvent,           this, &EventsWidget::onServerRoundOverEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onServerRoundOverPlayersEvent,    this, &EventsWidget::onServerRoundOverPlayersEvent);
    connect(m_commandHandler, &Frostbite2CommandHandler::onServerRoundOverTeamScoresEvent, this, &EventsWidget::onServerRoundOverTeamScoresEvent);

    /* Commands */
    // Misc
    connect(m_commandHandler, static_cast<void (FrostbiteCommandHandler::*)(bool)>(&FrostbiteCommandHandler::onLoginHashedCommand), this, &EventsWidget::onLoginHashedCommand);
}
Example #4
0
BF3::BF3(ServerEntry *serverEntry) : FrostbiteGame(serverEntry)
{
    con = new BF3Connection(this);
    con->hostConnect(serverEntry->host, serverEntry->port);

    levelDictionary = new BF3LevelDictionary(this);

    versionMap.insert(872601, "OB-E");
    versionMap.insert(873274, "OB-F");
    versionMap.insert(879322, "R3");
    versionMap.insert(879793, "R4");
    versionMap.insert(881071, "R5");
    versionMap.insert(882210, "R6");
    versionMap.insert(883137, "R7");
    versionMap.insert(883971, "R8");
    versionMap.insert(886605, "R9");
    versionMap.insert(888890, "R10");
    versionMap.insert(892188, "R11");
    versionMap.insert(893642, "R12");
    versionMap.insert(894307, "R13");
    versionMap.insert(894565, "R14");
    versionMap.insert(895012, "R15");
    versionMap.insert(895921, "R16");
    versionMap.insert(896646, "R17");
    versionMap.insert(903227, "R19");
    versionMap.insert(926998, "R20");
    versionMap.insert(933688, "R21");
    versionMap.insert(940924, "R22");
    versionMap.insert(948577, "R23");
    versionMap.insert(951336, "R24");
    versionMap.insert(951364, "R25");
    versionMap.insert(964189, "R26");
    versionMap.insert(972386, "R27");
    versionMap.insert(981883, "R28");
    versionMap.insert(1000930, "R29");
    versionMap.insert(1009356, "R30");
    versionMap.insert(1014305, "R31");
    versionMap.insert(1028652, "R32");
    versionMap.insert(1043704, "R32 1/2");
    versionMap.insert(1055290, "R33");
    versionMap.insert(1066226, "R34");
    versionMap.insert(1075133, "R34log");
    versionMap.insert(1097264, "R35");
    versionMap.insert(1125745, "R36");
    versionMap.insert(1139617, "R37");
    versionMap.insert(1149977, "R38");

    // Connection
    connect(con, SIGNAL(onConnected()), this, SLOT(onConnected()));

    // Commands
    connect(con, SIGNAL(onLoginHashedCommand(const QByteArray&)), this, SLOT(onLoginHashedCommand(const QByteArray&)));
    connect(con, SIGNAL(onLoginHashedCommand(bool)), this, SLOT(onLoginHashedCommand(bool)));
    connect(con, SIGNAL(onVersionCommand(const QString&, int)), this, SLOT(onVersionCommand(const QString&, int)));
}
Example #5
0
void DataThread::run()
{
  qDebug() << "thread started";
  QEventLoop eventLoop;
  QString login = m_settings.value("user").toString();
  QString password = m_settings.value("password").toString();
  if(login.isEmpty())
    login = "Mark";
  if(password.isEmpty())
    password = "test";

  m_loginQuery = new LoginQuery(login, password, parent());
  connect(m_loginQuery, SIGNAL(connected()), SLOT(onConnected()));
  connect(m_loginQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString)));
  m_loginQuery->doRequest();
  for(;;)
  {
    if(m_isConnected)
    {
      qDebug() << "connected: auth_token=" << m_loginQuery->getSession()->getUser()->getToken();
      emit(getFeed());
      //ToDo query RSS

    }
    else
    {
      m_loginQuery->doRequest();
    }

    eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents, 1000);
    QThread::msleep(5000);
  }
}
Example #6
0
void QTwitchChat::connect()
{
    if( channelName_ == "" )
        return;

    if( isShowSystemMessages() )
        emit newMessage( new QChatMessage( TWITCH_SERVICE, TWITCH_USER, "Connecting to " + channelName_ + "...", "", this ) );

    if( socket_)
    {
        if( socket_->state() == QAbstractSocket::ConnectedState )
            return;
        /*else
            reconnect();*/
    }

    socket_ = new QTcpSocket();

    QObject::connect( socket_, SIGNAL( connected() ), this, SLOT( onConnected() ) );
    QObject::connect( socket_, SIGNAL( readyRead() ), this, SLOT( parseMessage() ) );
    QObject::connect( socket_, SIGNAL( error( QAbstractSocket::SocketError ) ), this, SLOT( onSocketError() ) );

    //QObject::connect( socket_, SIGNAL( disconnected() ), this, SLOT( reconnect() ) );

    socket_->connectToHost( DEFAULT_TWITCH_CHAT_HOST_NAME, DEFAULT_TWITCH_CHAT_PORT_NUMBER );
}
Example #7
0
void TcpGateDialog::InitConnect()
{
	m_ndConnect.group = ui->gbConnect;
	m_ndConnect.cbIp = ui->cbCIP;
	m_ndConnect.spinPort = ui->spinCPort;
	m_ndConnect.lnSend = ui->lnCSendBytes;
	m_ndConnect.lnRecv = ui->lnCRecvBytes;
	m_ndConnect.leStatus = ui->leCStatus;
	m_ndConnect.btnStart = ui->btnConnect;	
	connect(m_ndConnect.btnStart, SIGNAL(clicked()), this, SLOT(onClkBtnConnect()));
		
	m_ndConnect.bConnected = false;
	m_ndConnect.bStarted = false;
	m_ndConnect.nSendBytes = 0;
	m_ndConnect.nRecvBytes = 0;	
	QSettings setting;
	m_ndConnect.latestIpList = setting.value("TcpGateTest/Connect/LatestIP", "").toStringList();
	int nCount = m_ndConnect.latestIpList.count();
	for (int i = nCount-1; i >= 0; i--)
	{
		if (!m_ndConnect.latestIpList[i].isEmpty())
		{
			m_ndConnect.cbIp->addItem(m_ndConnect.latestIpList[i]);
		}
	}
	
	m_ndConnect.tcpServer = NULL;	
	m_ndConnect.tcpSocket = new QTcpSocket(this);
	m_ndConnect.spinPort->setValue(setting.value("TcpGateTest/Connect/LatestPort", 5100).toInt());	
	connect(m_ndConnect.tcpSocket, SIGNAL(connected()), this, SLOT(onConnected()));
	connect(m_ndConnect.tcpSocket, SIGNAL(disconnected()), this, SLOT(onDisConnected()));
	connect(m_ndConnect.tcpSocket, SIGNAL(readyRead()), this, SLOT(onRead()));
	connect(m_ndConnect.tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
		this, SLOT(onNdcError(QAbstractSocket::SocketError)));
}
Example #8
0
Connection::Connection(int protocType,QObject *parent) :
    QTcpSocket(parent),packetSize(0),i_cmd_counter(0),i_dh(0),
    i_ackProtoc(PROTOC_NONE),i_protocType(protocType)
{
    connect(this, SIGNAL(readyRead()),
            this, SLOT(onControlSktReadyRead()));
    connect(this, SIGNAL(connected()),
            this, SLOT(onConnected()));

    //init data handler
    switch(i_protocType){
    case PROTOC_TCP:
        i_dh = new nProtocTCP::DHtcp(this);
        connect(i_dh, SIGNAL(sig_progressPercent(uint)),
                this, SIGNAL(sig_progressPercent(uint)));
        connect(i_dh, SIGNAL(sig_gotBlockSN(quint32)),
                this, SIGNAL(sig_gotBlockSN(quint32)));
        break;
    case PROTOC_UDP:
        i_dh = new nProtocUDP::DHudp(this);
        connect(i_dh, SIGNAL(sig_progressPercent(uint)),
                this, SIGNAL(sig_progressPercent(uint)));
        connect(i_dh, SIGNAL(sig_gotBlockSN(quint32)),
                this, SIGNAL(sig_gotBlockSN(quint32)));
        break;
    default:;
    }
}
void AbstractSocket::connectPrivateSignals()
{

    // Used to manage socket expiration timeout
    // Expiration delay is reinit when a bytes is writted
    connect(this, SIGNAL(bytesWritten(qint64)),
            this, SLOT(onBytesWritten(qint64)));

    // Used to manage socket expiration timeout
    // Expiration delay is reinit when data are available is read
    connect(this, SIGNAL(readyRead()),
            this, SLOT(onReadyRead()));

    // Those next signals are used as debug, for now
    connect(this, SIGNAL(connected()),
            this, SLOT(onConnected()));
    connect(this, SIGNAL(disconnected()),
            this, SLOT(onDisconnected()));
    connect(this, SIGNAL(error ( QAbstractSocket::SocketError)),
            this, SLOT(onError ( QAbstractSocket::SocketError)));
    connect(this, SIGNAL(hostFound ()),
            this, SLOT(onHostFound ()));
    connect(this, SIGNAL(proxyAuthenticationRequired ( const QNetworkProxy &, QAuthenticator *)),
            this, SLOT(onProxyAuthenticationRequired ( const QNetworkProxy &, QAuthenticator *)));
    connect(this, SIGNAL(stateChanged (QAbstractSocket::SocketState)),
            this, SLOT(onStateChanged (QAbstractSocket::SocketState)));
    connect(this, SIGNAL(aboutToClose()),
            this, SLOT(onAboutToClose()));
    connect(this, SIGNAL(readChannelFinished()),
            this, SLOT(onReadChannelFinished()));
}
Example #10
0
void GeneratorDaemon::run()
{
  qDebug() << "thread started";
  QEventLoop eventLoop;
  m_loginQuery = new LoginQuery("DemoUser", "test", this);
  connect(m_loginQuery, SIGNAL(connected()), SLOT(onConnected()));
  connect(m_loginQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString)));
  m_loginQuery->doRequest();
  for (;;)
  {
    if (m_isConnected)
    {
      qDebug() << "connected: auth_token=" << m_loginQuery->getUser()->getToken();
      qDebug() << "tagQuery " << m_tagQuery;
      if (m_tagQuery)
      {
        for (int i=0;i<m_marks.size();i++)
        {
          m_tagQuery->getTag()->setTime(QDateTime::currentDateTime());
          m_tagQuery->getTag()->setLatitude(m_marks.at(i).x());
          m_tagQuery->getTag()->setLongitude(m_marks.at(i).y());
          m_tagQuery->doRequest();
          qDebug() << "adding mark";
          eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents, 1000);
          QThread::msleep(5000);
        }
      }
    }
    eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents, 1000);
    QThread::msleep(5000);
  }
}
/*!
  Initializes the client and connects to \a remoteService.
*/
void BluetoothClient::startClient(const QBluetoothServiceInfo &remoteService)
{
    if (mSocket || mRetries) {
        qDebug() << "BluetoothClient::startClient(): Already running!";
        return;
    }

    mService = remoteService;
    mRetries = NumberOfRetries;
    mLastErrorString = "";

    Common::resetBuffer();

    QBluetoothAddress address = mService.device().address();
    qDebug() << "BluetoothClient::startClient(): Bluetooth address: " << address.toString();

    mSocket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
    connect(mSocket, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
    connect(mSocket, SIGNAL(connected()), this, SLOT(onConnected()));
    connect(mSocket, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
    connect(mSocket, SIGNAL(error(QBluetoothSocket::SocketError)),
            this, SLOT(onSocketError(QBluetoothSocket::SocketError)));

    // mSocket->connectToService() call may block the UI thread. Thus, use the
    // the timer to delay the call in case we want to show some note for the
    // user.
    QTimer::singleShot(RetryInterval, this, SLOT(connectToService()));
}
void InsteonNetwork::connect(InsteonConnection *connect)
{
	messenger->connect(connect);
	connection = connect;
	controller = new InsteonController(this);
	onConnected();
}
Example #13
0
void SecureFileUploader::upload(const QString &localFile, const QString &dest, const QString &host,
                                const QString &username, const QString &passwd)
{
    QFileInfo info(localFile);

    m_localFilename = info.canonicalFilePath();
    m_remoteFilename = dest + "/" + info.fileName();

    QSsh::SshConnectionParameters params;
    params.host = host;
    params.userName = username;
    params.password = passwd;
    params.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePassword;
    params.timeout = 30;
    params.port = 22;

    m_connection = new QSsh::SshConnection(params, this); // TODO free this pointer!

    connect(m_connection, SIGNAL(connected()), SLOT(onConnected()));
    connect(m_connection, SIGNAL(error(QSsh::SshError)), SLOT(onConnectionError(QSsh::SshError)));

    qDebug() << "SecureUploader: Connecting to host" << host;

    m_connection->connectToHost();
}
Example #14
0
void MainWindow::on_connectButton_clicked()
{
    if(m_connectionState == ConnectionState::Disconnected)
    {
        QString host = ui->hostLineEdit->text();
        quint16 port = ui->portSpinBox->value();
        QString name = ui->nameLineEdit->text();

        m_tcpClient.reset(new nc::TcpClient);
        m_gameState.reset(new GameState(host, port, name, *m_tcpClient.get()));

        connect(m_tcpClient.get(), SIGNAL(messageRead(QByteArray)), m_gameState.get(), SLOT(onInboundMessage(QByteArray)));
        connect(m_gameState.get(), SIGNAL(outboundMessage(QByteArray)), m_tcpClient.get(), SLOT(writeMessage(QByteArray)));
        connect(m_gameState.get(), SIGNAL(chatMessageReceived(QString)), this, SLOT(onChatMessageReceived(QString)));
        connect(m_gameState.get(), SIGNAL(disconnectedFromServer(QString)), this, SLOT(onDisconnected(QString)));
        connect(this, SIGNAL(chatMessageSent(QString)), m_gameState.get(), SLOT(onChatMessageSent(QString)));
        connect(m_tcpClient.get(), SIGNAL(connected()), this, SLOT(onConnected()));
        connect(m_tcpClient.get(), SIGNAL(disconnected()), this, SLOT(onDisconnected()));
        connect(m_tcpClient.get(), SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));

        m_tcpClient->connectToHost(host, port);
        changeConnectionState(ConnectionState::Connecting);

        qDebug() << "Connecting.";
        appendHtml(QString("<b>Connecting to %1:%2.</b><br>").arg(host).arg(port));
    }
    else
    {
        m_tcpClient->disconnectFromHost();
    }
}
Example #15
0
void SettingsEditorForm::connectToHost(QString addr, int port)
{
    if(_socket != nullptr)
    {
        _socket->close();
        _socket->deleteLater();
    }

    _socket = new QSslSocket(this);
    connect( _socket, SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(onSocketError(QAbstractSocket::SocketError)));

    connect( _socket, SIGNAL(peerVerifyError(QSslError)), this, SLOT(onPeerVerifyError(QSslError)) );
    connect( _socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(onSslErrors(QList<QSslError>)));

    connect( _socket, SIGNAL(connected()),this,SLOT(onConnected()));
    connect( _socket, SIGNAL(readyRead()), this, SLOT(onReadyRead()));

    _socket->setLocalCertificate( "./certs/manager.crt"  );
    _socket->setPrivateKey( "./certs/manager.key");

    _socket->setProtocol(QSsl::SecureProtocols);

    _socket->setCaCertificates(QSslCertificate::fromPath("./certs/trusted.pem"));

    _socket->connectToHostEncrypted( addr, port, "SettingsServer");

    if(!_socket->waitForEncrypted(1000))
    {
        LoggerDialog::get()->Error("SettingsEditorForm::connectToHost","Wait for encrypted failed!");
        _socket->close();
        ui->pushButton_connect->setText("Connect");
    }
}
VpnControlDaemonClient::VpnControlDaemonClient(bool /* fSynchronous */) : QObject(NULL), m_pStream(new QTextStream), m_pSocket(new QLocalSocket)
{
   m_pStream->setDevice(m_pSocket);
   connect(m_pSocket, SIGNAL(connected()), SLOT(onConnected()));
   connect(m_pSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), SLOT(onDisconnected()));
   connect(m_pSocket, SIGNAL(disconnected()), SLOT(onDisconnected()));
}
Example #17
0
Connector::Connector(QObject *parent) : QObject(parent)
{
    connect(&cliSocket, SIGNAL(connected()), this, SLOT(onConnected()));
    connect(&cliSocket, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
    connect(&cliSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMsg(QString)));

}
Example #18
0
// PRIVATE: Socket connection methods
void MainWindow::connectSocket()
{
    Q_ASSERT(nullptr == _socket);

    _socket = new QTcpSocket();

    _socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);

    // TcpSocket: Connect signals and slots
    bool isOk;

    isOk = connect(_socket, SIGNAL(readyRead()), this, SLOT(onDataRecieved()));
    Q_ASSERT(isOk);
    Q_UNUSED(isOk);

    isOk = connect(_socket, SIGNAL(connected()), this, SLOT(onConnected()));
    Q_ASSERT(isOk);
    Q_UNUSED(isOk);

    isOk = connect(_socket, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
    Q_ASSERT(isOk);
    Q_UNUSED(isOk);

    isOk = connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)),
                   this, SLOT(onErrorSocket(QAbstractSocket::SocketError)));
    Q_ASSERT(isOk);
    Q_UNUSED(isOk);

    _socket->connectToHost(_programSettings.server.ipV4Address,
                           _programSettings.server.port);
    setWindowTitle(QString("%1 " + tr("Connecting...") + " %2:%3")
                   .arg(_programSettings.application.name)
                   .arg(_programSettings.server.ipV4Address)
                   .arg(_programSettings.server.port));
}
Example #19
0
SocketIOClient::SocketIOClient(QObject *parent) :
    QObject(parent),
    m_pWebSocket(0),
    m_pNetworkAccessManager(0),
    m_requestUrl(),
    m_mustMask(true),
    m_connectionTimeout(30000),
    m_heartBeatTimeout(20000),
    m_pHeartBeatTimer(0),
    m_sessionId()
{
    m_pWebSocket = new QWebSocket(QString(), QWebSocketProtocol::V_LATEST, this);
    m_pNetworkAccessManager = new QNetworkAccessManager(this);
    m_pHeartBeatTimer = new QTimer(this);
    m_pHeartBeatTimer->setInterval(m_heartBeatTimeout);

    connect(m_pWebSocket, SIGNAL(connected()), this,SLOT(onConnected()));
    connect(m_pWebSocket, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
    connect(m_pWebSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onError(QAbstractSocket::SocketError)));
    connect(m_pWebSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMessage(QString)));
    connect(m_pWebSocket, SIGNAL(binaryMessageReceived(QByteArray)), this, SLOT(onBinaryMessage(QByteArray)));

    connect(m_pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));

    connect(m_pHeartBeatTimer, SIGNAL(timeout()), this, SLOT(sendHeartBeat()));

    //socket.io connections
    connect(this, SIGNAL(handshakeSucceeded()), this, SLOT(onHandshakeSucceeded()));

    //socket.io test connections
    connect(this, SIGNAL(heartbeatReceived()), this, SLOT(onHeartbeatReceived()));
}
Example #20
0
void CoreClient::handleStanzaChannelAvailableChanged(bool available) {
	if (available) {
		iqRouter_->setJID(session_->getLocalJID());
		handleConnected();
		onConnected();
	}
}
Example #21
0
		bool						Listener::_onConnected(intptr_t s)
		{
			if(_queuing_connections)
				return _queued_sockets.enq(s);
			else
				return onConnected(s);
		}
Example #22
0
void
CTCPSocket::connect(const CNetworkAddress& addr)
{
	{
		CLock lock(&m_mutex);

		// fail on attempts to reconnect
		if (m_socket == NULL || m_connected) {
			sendConnectionFailedEvent("busy");
			return;
		}

		try {
			if (ARCH->connectSocket(m_socket, addr.getAddress())) {
				sendEvent(getConnectedEvent());
				onConnected();
			}
			else {
				// connection is in progress
				m_writable = true;
			}
		}
		catch (XArchNetwork& e) {
			throw XSocketConnect(e.what());
		}
	}
	setJob(newJob());
}
SmppClient::SmppClient(const QString &smppUserName, const QString &smppPassword, QObject *parent) :
    QObject(parent),
    m_transport(new QTcpSocket(this)),
    m_timer(new QTimer(this)),
    m_timerForEnquireLink(new QTimer(this)),
    m_smppUserName(smppUserName),
    m_smppPassword(smppPassword)
{
    static bool firstTime = true;
    if (firstTime) {
        firstTime = false;
        qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
        qRegisterMetaType<SmppClient::SmsStates>("SmppClient::SmsStates");
        qRegisterMetaType<SmppClient::DisconnectReason>("SmppClient::DisconnectReason");
    }
    m_timerForEnquireLink->setInterval(EnquireLinkInterval);
    connect(m_transport, SIGNAL(readyRead()),
            this, SLOT(onReadyRead()));
    connect(m_transport, SIGNAL(connected()),
            this, SLOT(onConnected()));
    connect(m_transport, SIGNAL(disconnected()),
            this, SLOT(onDisconnected()));
    connect(m_transport, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(onError(QAbstractSocket::SocketError)));

    connect(m_timer, SIGNAL(timeout()),
            this, SLOT(onTimeout()));

    connect(m_timerForEnquireLink, SIGNAL(timeout()),
            this, SLOT(onEnquireLinkTimeout()));
}
Example #24
0
Connection::Connection():
	objectFactory(*this)
{
	QObject::connect(&serverProcess, SIGNAL(started()), this, SLOT(onServerStarted()));
	QObject::connect(&serverProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onServerError(QProcess::ProcessError)));
	QObject::connect(&socket, SIGNAL(connected()), this, SLOT(onConnected()));
}
 static void onAxisEvent(const std::string& vendorName, int controllerID, AndroidControllerCode axisCode, float value, bool isAnalog)
 {
     // log("vendorName: %s, controller id: %d, axis: %d, value: %f", vendorName.c_str(), controllerID, axisCode, value);
     auto iter = findController(vendorName, controllerID);
     if (iter == Controller::_controllers.end())
     {
         onConnected(vendorName, controllerID);
         iter = findController(vendorName, controllerID);
     }
     auto gamepad = (*iter)->getGamepad();
     auto thiz = (*iter)->getImpl();
     switch (axisCode)
     {
         case AndroidControllerCode::THUMBSTICK_LEFT_X:
             thiz->sendEventAxis(gamepad->getLeftThumbstick()->getAxisX(), value, isAnalog);
             break;
         case AndroidControllerCode::THUMBSTICK_LEFT_Y:
             thiz->sendEventAxis(gamepad->getLeftThumbstick()->getAxisY(), value, isAnalog);
             break;
         case AndroidControllerCode::THUMBSTICK_RIGHT_X:
             thiz->sendEventAxis(gamepad->getRightThumbstick()->getAxisX(), value, isAnalog);
             break;
         case AndroidControllerCode::THUMBSTICK_RIGHT_Y:
             thiz->sendEventAxis(gamepad->getRightThumbstick()->getAxisY(), value, isAnalog);
             break;
         default:
             CCASSERT(false, "Invalid controller axis code!");
             break;
     }
 }
Example #26
0
SayHelloService::SayHelloService(MessageBus &messageBus, QObject *parent) :
	QObject(parent),
	m_messageBus(messageBus),
	m_serviceName("com.barco.cirrus.sayhelloservice"),
	m_sayHelloTest()
{
	connect(&m_messageBus, SIGNAL(connected(QString)), this, SLOT(onConnected()));
}
Example #27
0
HRESULT CPipeServer::handleConnectedEvent(Channel* channel)
{
	if (onConnected) {
		HR_ASSERT_OK(onConnected(channel->index));
	}

	return S_OK;
}
VpnControlDaemonClient::VpnControlDaemonClient(QObject* pParent) : QObject(pParent), m_pStream(new QTextStream), m_pSocket(new QLocalSocket)
{
   m_pStream->setDevice(m_pSocket);
   connect(m_pSocket, SIGNAL(connected()), SLOT(onConnected()));
   connect(m_pSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), SLOT(onDisconnected()));
   connect(m_pSocket, SIGNAL(disconnected()), SLOT(onDisconnected()));
   connect(m_pSocket, SIGNAL(readyRead()), SLOT(onReadyRead()));
}
Example #29
0
void testSocket::connect(const vmime::string& address, const vmime::port_t port)
{
	m_address = address;
	m_port = port;
	m_connected = true;

	onConnected();
}
Example #30
0
ScrobSocket::ScrobSocket( QObject* parent ) : QTcpSocket( parent )
{
    connect( this, SIGNAL(readyRead()), SLOT(onReadyRead()) );    
    connect( this, SIGNAL(error( QAbstractSocket::SocketError )), SLOT(onError( QAbstractSocket::SocketError )) );
    connect( this, SIGNAL(connected()), SLOT(onConnected()) );
    connect( this, SIGNAL(disconnected()), SLOT(onDisconnected()) );
    transmit( "INIT c=bof\n" );
}