示例#1
0
RemoteClient::RemoteClient(Application* app, QTcpSocket* client)
  : app_(app),
    downloader_(false),
    client_(client)
{
  // Open the buffer
  buffer_.setData(QByteArray());
  buffer_.open(QIODevice::ReadWrite);
  reading_protobuf_ = false;

  // Connect to the slot IncomingData when receiving data
  connect(client, SIGNAL(readyRead()), this, SLOT(IncomingData()));

  // Check if we use auth code
  QSettings s;

  s.beginGroup(NetworkRemote::kSettingsGroup);
  use_auth_code_ = s.value("use_auth_code", false).toBool();
  auth_code_     = s.value("auth_code", 0).toInt();
  allow_downloads_ = s.value("allow_downloads", false).toBool();

  s.endGroup();

  // If we don't use an auth code, we don't need to authenticate the client.
  authenticated_ = !use_auth_code_;
}
示例#2
0
QUdpClient::QUdpClient( QTextCodec* pCodec, QObject *parent) :
    QMyUdpSocket(parent)
{
    pTextCodec = pCodec;
     setObjectName( "QUdpClient" );
     connect( this, SIGNAL( readyRead( ) ), this, SLOT( IncomingData( ) ) );
     connect( this, SIGNAL( error( QAbstractSocket::SocketError ) ), this, SLOT( HandleError( QAbstractSocket::SocketError ) ) );
}
void PanoServerTCP::NewConnection() {
  // Open Socket to client.
  QTcpSocket* conn = server_->nextPendingConnection();
  
  if (!conn) {
    log("ERROR: can't establish connection to host.");
    return;
  }
  
  log (QString("Connected to peer :") + conn->peerAddress().toString());
  connections_.push_back(TcpConnection(conn));
  
  latest_conn_ = conn;
  QTimer::singleShot(500, this, SLOT(SendAllImages()));
  
  connect(conn, SIGNAL(readyRead()), this, SLOT(IncomingData()));
  connect(conn, SIGNAL(disconnected()), this, SLOT(ConnectionClosed()));
}
示例#4
0
bool CSocket::IncomingConnection() const
{
	// if there is incoming data and we are listening then there
	// is an incoming connection
	return (m_bListening && IncomingData());
}