mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] send host info when connected
This commit is contained in:
@@ -194,25 +194,6 @@ int Render::StartScreenCapturer() {
|
||||
|
||||
int screen_capturer_init_ret = screen_capturer_->Init(
|
||||
60, [this](unsigned char* data, int size, int width, int height) -> void {
|
||||
if (!hostname_sent_ && width > 0 && height > 0 &&
|
||||
start_screen_capturer_) {
|
||||
original_display_width_ = width;
|
||||
original_display_height_ = height;
|
||||
std::string host_name = GetHostName();
|
||||
RemoteAction remote_action;
|
||||
remote_action.type = ControlType::host_infomation;
|
||||
memcpy(&remote_action.i.host_name, host_name.data(),
|
||||
host_name.size());
|
||||
remote_action.i.host_name_size = host_name.size();
|
||||
remote_action.i.origin_display_height = original_display_height_;
|
||||
remote_action.i.origin_display_width = original_display_width_;
|
||||
int ret = SendDataFrame(peer_, (const char*)&remote_action,
|
||||
sizeof(remote_action));
|
||||
if (0 == ret) {
|
||||
hostname_sent_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
auto now_time = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch())
|
||||
.count();
|
||||
@@ -842,6 +823,21 @@ void Render::MainLoop() {
|
||||
is_create_connection_ =
|
||||
CreateConnection(peer_, client_id_, password_saved_) ? false : true;
|
||||
}
|
||||
|
||||
if (!host_info_sent_ && screen_width_ > 0 && screen_height_ > 0) {
|
||||
std::string host_name = GetHostName();
|
||||
RemoteAction remote_action;
|
||||
remote_action.type = ControlType::host_infomation;
|
||||
memcpy(&remote_action.i.host_name, host_name.data(), host_name.size());
|
||||
remote_action.i.host_name_size = host_name.size();
|
||||
remote_action.i.origin_display_width = screen_width_;
|
||||
remote_action.i.origin_display_height = screen_height_;
|
||||
int ret = SendDataFrame(peer_, (const char*)&remote_action,
|
||||
sizeof(remote_action));
|
||||
if (0 == ret) {
|
||||
host_info_sent_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -305,9 +305,7 @@ class Render {
|
||||
bool need_to_rejoin_ = false;
|
||||
bool just_created_ = false;
|
||||
std::string controlled_remote_id_ = "";
|
||||
int original_display_width_ = 0;
|
||||
int original_display_height_ = 0;
|
||||
bool hostname_sent_ = false;
|
||||
bool host_info_sent_ = false;
|
||||
SDL_Event last_mouse_event;
|
||||
|
||||
// stream window render
|
||||
|
||||
@@ -375,7 +375,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
|
||||
render->start_mouse_controller_ = false;
|
||||
render->start_keyboard_capturer_ = false;
|
||||
render->control_mouse_ = false;
|
||||
render->hostname_sent_ = false;
|
||||
render->host_info_sent_ = false;
|
||||
props->connection_established_ = false;
|
||||
props->mouse_control_button_pressed_ = false;
|
||||
if (props->dst_buffer_) {
|
||||
@@ -410,6 +410,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
|
||||
|
||||
switch (status) {
|
||||
case ConnectionStatus::Connected:
|
||||
render->host_info_sent_ = false;
|
||||
render->start_screen_capturer_ = true;
|
||||
render->start_mouse_controller_ = true;
|
||||
break;
|
||||
@@ -417,9 +418,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
|
||||
render->start_screen_capturer_ = false;
|
||||
render->start_mouse_controller_ = false;
|
||||
render->start_keyboard_capturer_ = false;
|
||||
render->hostname_sent_ = false;
|
||||
render->original_display_width_ = 0;
|
||||
render->original_display_height_ = 0;
|
||||
render->host_info_sent_ = false;
|
||||
if (props) props->connection_established_ = false;
|
||||
if (render->audio_capture_) {
|
||||
render->StopSpeakerCapturer();
|
||||
|
||||
Reference in New Issue
Block a user