コード例 #1
0
ファイル: widget.cpp プロジェクト: krdcl/USpeak
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    connector = new Server(this);



    myself.setName(QString("user ") + QString::number(qrand()));

    // connect(connector,SIGNAL(massageReceived(QByteArray)),this,SLOT(audioOutput(QByteArray))); \\

    connect(connector,SIGNAL(massageReceived(QByteArray)),this,SLOT(audioOutput(QByteArray))); \

    decoder = new AudioDecoder(this);
    recorder = new AudioRecorder(this);
    connect(recorder,SIGNAL(audioBufferder(QByteArray)), connector, SLOT(sendMessage(QByteArray)));

    ui->message_output->setReadOnly(true);
    ui->text_log->setReadOnly(true);


    QString host_rand = QString::number(rand() * 255) + QString(".") +
            QString::number(rand() * 255) + QString(".") +
            QString::number(rand() * 255) + QString(".") +
            QString::number(rand() * 255);
    // QHostAddress host = QHostAddress(host_rand);
    // QHostAddress host =  QHostAddress::LocalHost ;;
    QHostAddress host =  QHostAddress::Broadcast;
    connector->setPort(qrand());
    connector->setHostAdress(host);
    connector->bindHostPort();

    // connector->joinMulticastGroup(host);

    client_tcp = new ClientTcp(this);
    server_tcp = new ServerTCP(this);
    connect(client_tcp,SIGNAL(sendedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(client_tcp,SIGNAL(receivedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(client_tcp,SIGNAL(connected()),this,SLOT(serverFounded()));

    //connect(server_tcp,SIGNAL(),this,SLOT());
    connect(server_tcp,SIGNAL(sendedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(server_tcp,SIGNAL(receivedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(server_tcp,SIGNAL(newConnection()),this,SLOT(clientConnected()));

    QHostAddress hosta("127.15.10.12");

    quint16 port = 135665;
    client_tcp->setHostAdress(hosta);
    client_tcp->setPort(port);

    server_tcp->setHostAdress(hosta);
    server_tcp->setPort(port);
    //    connecor->ho



}
コード例 #2
0
void GrabberConsoleWidget::setInterface(GrabberInterface *grabberinterface, GrabberThread *grabberThread)
{
    _grabberinterface = grabberinterface;
    _grabberThread = grabberThread;

    connect(_grabberinterface, SIGNAL(messageOutput(QString)), this, SLOT(messageOutput(QString)), Qt::QueuedConnection);
    connect(_grabberinterface, SIGNAL(updateEventCounter(int)), this, SLOT(updateEventCounter(int)), Qt::QueuedConnection);
    connect(_grabberinterface, SIGNAL(grabberStatusChanged()), this, SLOT(grabberStatusChanged()), Qt::QueuedConnection);

    useEventCounterCheckbox->setChecked(true);
}
コード例 #3
0
ファイル: widget.cpp プロジェクト: krdcl/USpeak
void Widget::on_send_button_clicked()
{
    QString message = "\nFrom: ";
    message += myself.getName();
    message += "\nWhen: ";
    message += QTime::currentTime().toString();
    message += " ";
    message += QDate::currentDate().toString();
    message += "\nText:\n";
    message += (this->ui->message_input->toPlainText());
    messageOutput(message);
    this->ui->message_input->setPlainText("");
    this->ui->message_input->setFocus();

    // connecor->bind(QHostAddress::LocalHost, connecor->getPort());
    connector->sendMessage(message.toLocal8Bit());
    if (!client_or_server)
    {
        logOutput(" server_tcp->sendMessageToAllClients(message.toLocal8Bit());");
        server_tcp->sendMessageToAllClients(message.toLocal8Bit());
    }
    else
    {
        logOutput("client_tcp->writeMessage(message.toLocal8Bit());");
        client_tcp->writeMessage(message.toLocal8Bit());
    }
}