Only server can capture screen and control mouse

This commit is contained in:
dijunkun
2024-06-07 14:07:22 +08:00
parent efb165b56f
commit 4b3839aa34
3 changed files with 8 additions and 2 deletions

View File

@@ -499,6 +499,7 @@ int MainWindow::Run() {
!connection_established_) { !connection_established_) {
ret = JoinConnection(peer_, remote_id_, client_password_); ret = JoinConnection(peer_, remote_id_, client_password_);
if (0 == ret) { if (0 == ret) {
is_client_ = true;
} }
} else if (connect_button_label_ == } else if (connect_button_label_ ==
@@ -511,6 +512,7 @@ int MainWindow::Run() {
is_create_connection_ = false; is_create_connection_ = false;
connection_established_ = false; connection_established_ = false;
received_frame_ = false; received_frame_ = false;
is_client_ = false;
} }
if (0 == ret) { if (0 == ret) {
@@ -842,6 +844,7 @@ int MainWindow::Run() {
// Cleanup // Cleanup
if (is_create_connection_) { if (is_create_connection_) {
LeaveConnection(peer_); LeaveConnection(peer_);
is_client_ = false;
} }
if (peer_) { if (peer_) {

View File

@@ -98,6 +98,7 @@ class MainWindow {
char input_password_[7] = ""; char input_password_[7] = "";
char remote_id_[20] = ""; char remote_id_[20] = "";
char client_password_[20] = ""; char client_password_[20] = "";
bool is_client_ = false;
private: private:
int screen_width_ = 1280; int screen_width_ = 1280;

View File

@@ -154,8 +154,10 @@ void MainWindow::OnConnectionStatusCb(ConnectionStatus status,
} else if (ConnectionStatus::Connected == status) { } else if (ConnectionStatus::Connected == status) {
main_window->connection_status_str_ = "Connected"; main_window->connection_status_str_ = "Connected";
main_window->connection_established_ = true; main_window->connection_established_ = true;
if (!main_window->is_client_) {
main_window->start_screen_capture_ = true; main_window->start_screen_capture_ = true;
main_window->start_mouse_control_ = true; main_window->start_mouse_control_ = true;
}
} else if (ConnectionStatus::Disconnected == status) { } else if (ConnectionStatus::Disconnected == status) {
main_window->connection_status_str_ = "Disconnected"; main_window->connection_status_str_ = "Disconnected";
} else if (ConnectionStatus::Failed == status) { } else if (ConnectionStatus::Failed == status) {