main: Use 1 client cleanup function

rsa-aes
Andri Yngvason 2023-09-03 18:25:59 +00:00
parent 0b6229df5b
commit 31e19757d1
1 changed files with 24 additions and 30 deletions

View File

@ -1038,6 +1038,30 @@ static struct wayvnc_client* client_create(struct wayvnc* wayvnc,
static void client_destroy(void* obj)
{
struct wayvnc_client* self = obj;
struct nvnc* nvnc = nvnc_client_get_server(self->nvnc_client);
struct wayvnc* wayvnc = nvnc_get_userdata(nvnc);
if (self->seat)
self->seat->occupancy--;
wayvnc->nr_clients--;
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
wayvnc->nr_clients);
struct ctl_server_client_info info = {
.id = self->id,
.hostname = nvnc_client_get_hostname(self->nvnc_client),
.username = nvnc_client_get_auth_username(self->nvnc_client),
.seat = self->seat->name,
};
ctl_server_event_disconnected(wayvnc->ctl, &info, wayvnc->nr_clients);
if (wayvnc->nr_clients == 0) {
nvnc_log(NVNC_LOG_INFO, "Stopping screen capture");
screencopy_stop(&wayvnc->screencopy);
stop_performance_ticker(wayvnc);
}
if (self->keyboard.virtual_keyboard) {
zwp_virtual_keyboard_v1_destroy(
@ -1054,35 +1078,6 @@ static void client_destroy(void* obj)
free(self);
}
static void on_nvnc_client_cleanup(struct nvnc_client* client)
{
struct wayvnc_client* wayvnc_client = nvnc_get_userdata(client);
struct nvnc* nvnc = nvnc_client_get_server(client);
struct wayvnc* self = nvnc_get_userdata(nvnc);
if (wayvnc_client->seat)
wayvnc_client->seat->occupancy--;
self->nr_clients--;
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
self->nr_clients);
struct ctl_server_client_info info = {
.id = wayvnc_client->id,
.hostname = nvnc_client_get_hostname(client),
.username = nvnc_client_get_auth_username(client),
.seat = wayvnc_client->seat->name,
};
ctl_server_event_disconnected(self->ctl, &info, self->nr_clients);
if (self->nr_clients == 0) {
nvnc_log(NVNC_LOG_INFO, "Stopping screen capture");
screencopy_stop(&self->screencopy);
stop_performance_ticker(self);
}
}
static void on_nvnc_client_new(struct nvnc_client* client)
{
struct nvnc* nvnc = nvnc_client_get_server(client);
@ -1098,7 +1093,6 @@ static void on_nvnc_client_new(struct nvnc_client* client)
wayvnc_start_capture_immediate(self);
}
self->nr_clients++;
nvnc_set_client_cleanup_fn(client, on_nvnc_client_cleanup);
nvnc_log(NVNC_LOG_DEBUG, "Client connected, new client count: %d",
self->nr_clients);