diff --git a/client_qt5/mainwindow.cpp b/client_qt5/mainwindow.cpp index 563870a..1d319c8 100644 --- a/client_qt5/mainwindow.cpp +++ b/client_qt5/mainwindow.cpp @@ -139,8 +139,6 @@ MainWindow::MainWindow(QWidget *parent) onNetworkChanged(NetworkState::Disconnected); toggleAdvancedMode(false); showMessage("F1: help F2: toggle mode (advanced/easy mode)"); - ui->radioButton_udp->toggle(); - ui->radioButton_kcp_udp->setEnabled(false); } @@ -217,7 +215,6 @@ void MainWindow::onNetworkChanged(const NetworkState networkState){ if(mainThreadId_ == std::this_thread::get_id()){ switch(networkState){ case NetworkState::Disconnected: { - ui->groupBox_protocol->setEnabled(true); ui->lineEdit_serverHost->setEnabled(true); ui->lineEdit_serverPort->setEnabled(true); ui->checkBox_needAec->setEnabled(true); @@ -228,7 +225,6 @@ void MainWindow::onNetworkChanged(const NetworkState networkState){ break; } case NetworkState::Connecting: { - ui->groupBox_protocol->setEnabled(false); ui->lineEdit_serverHost->setEnabled(false); ui->lineEdit_serverPort->setEnabled(false); ui->checkBox_needAec->setEnabled(false); @@ -237,7 +233,6 @@ void MainWindow::onNetworkChanged(const NetworkState networkState){ break; } case NetworkState::Connected: { - ui->groupBox_protocol->setEnabled(false); ui->lineEdit_serverHost->setEnabled(false); ui->lineEdit_serverPort->setEnabled(false); ui->checkBox_needAec->setEnabled(false); @@ -305,15 +300,7 @@ void MainWindow::gotoWork(){ root_.put("server.host", ui->lineEdit_serverHost->text().toStdString().c_str()); root_.put("server.port", ui->lineEdit_serverPort->text().toStdString().c_str()); - if (ui->radioButton_tcp->isChecked()) { - root_.put("protocol", "raw_tcp"); - } - else if (ui->radioButton_udp->isChecked()) { root_.put("protocol", "raw_udp"); - } - else if (ui->radioButton_kcp_udp->isChecked()) { - root_.put("protocol", "kcp_udp"); - } worker_ = IWorker::create(); diff --git a/client_qt5/mainwindow.ui b/client_qt5/mainwindow.ui index dec8cb9..e0e075a 100644 --- a/client_qt5/mainwindow.ui +++ b/client_qt5/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 600 - 460 + 339 @@ -359,7 +359,7 @@ 20 150 250 - 171 + 71 @@ -388,64 +388,12 @@ 80 - - - - 10 - 54 - 231 - 111 - - - - protocol - - - - - 10 - 50 - 111 - 23 - - - - Raw TCP - - - - - - 10 - 80 - 111 - 23 - - - - KCP/UDP - - - - - - 10 - 20 - 111 - 23 - - - - Raw UDP - - - 20 - 340 + 250 250 61 @@ -471,7 +419,7 @@ 289 10 300 - 421 + 301 @@ -541,7 +489,7 @@ 10 160 270 - 251 + 131 diff --git a/server/Server.cpp b/server/Server.cpp index 3187b48..7f7f5e1 100644 --- a/server/Server.cpp +++ b/server/Server.cpp @@ -19,7 +19,7 @@ void printUsage() { -int main(int argc, char* argv[]) { +int main____(int argc, char* argv[]) { std::shared_ptr server_ = nullptr; try { int port = 80; @@ -73,4 +73,52 @@ int main(int argc, char* argv[]) { } return 0; +} + + +int main(int argc, char* argv[]) { + std::shared_ptr server_ = nullptr; + try { + int port = 80; + + if ((argc != 2)&&(argc != 3)) { + printUsage(); + return -1; + } + + + if (argc == 3) { + if (!strcmp("broadcast", argv[2])) { + isEchoMode = false; + } + else if (!strcmp("echo", argv[2])) { + isEchoMode = true; + } + else { + printUsage(); + return -1; + } + } + + + port = std::atoi(argv[1]); + + + LOGI << "PORT=" << port; + if (isEchoMode ) LOGI<< "ECHO MODE"; + + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace); + + boost::asio::io_service io_service; + + server_ = std::make_shared(io_service, port); + + + io_service.run(); + } + catch (std::exception& e) { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; } \ No newline at end of file