Add seat name to client-connected event
parent
d53a04b5b0
commit
87c034db43
|
@ -70,15 +70,11 @@ struct cmd_response* cmd_ok(void);
|
||||||
struct cmd_response* cmd_failed(const char* fmt, ...);
|
struct cmd_response* cmd_failed(const char* fmt, ...);
|
||||||
|
|
||||||
void ctl_server_event_connected(struct ctl*,
|
void ctl_server_event_connected(struct ctl*,
|
||||||
const char* client_id,
|
const struct ctl_server_client_info *info,
|
||||||
const char* client_hostname,
|
|
||||||
const char* client_username,
|
|
||||||
int new_connection_count);
|
int new_connection_count);
|
||||||
|
|
||||||
void ctl_server_event_disconnected(struct ctl*,
|
void ctl_server_event_disconnected(struct ctl*,
|
||||||
const char* client_id,
|
const struct ctl_server_client_info *info,
|
||||||
const char* client_hostname,
|
|
||||||
const char* client_username,
|
|
||||||
int new_connection_count);
|
int new_connection_count);
|
||||||
|
|
||||||
void ctl_server_event_capture_changed(struct ctl*,
|
void ctl_server_event_capture_changed(struct ctl*,
|
||||||
|
|
|
@ -856,15 +856,18 @@ struct cmd_response* cmd_failed(const char* fmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
json_t* pack_connection_event_params(
|
json_t* pack_connection_event_params(
|
||||||
const char* client_id,
|
const struct ctl_server_client_info *info,
|
||||||
const char* client_hostname,
|
|
||||||
const char* client_username,
|
|
||||||
int new_connection_count)
|
int new_connection_count)
|
||||||
{
|
{
|
||||||
return json_pack("{s:s, s:s?, s:s?, s:i}",
|
// TODO: Why is the id a string?
|
||||||
"id", client_id,
|
char id_str[64];
|
||||||
"hostname", client_hostname,
|
snprintf(id_str, sizeof(id_str), "%d", info->id);
|
||||||
"username", client_username,
|
|
||||||
|
return json_pack("{s:s, s:s?, s:s?, s:s?, s:i}",
|
||||||
|
"id", id_str,
|
||||||
|
"hostname", info->hostname,
|
||||||
|
"username", info->username,
|
||||||
|
"seat", info->seat,
|
||||||
"connection_count", new_connection_count);
|
"connection_count", new_connection_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,34 +909,28 @@ int ctl_server_enqueue_event(struct ctl* self, enum event_type evt_type,
|
||||||
|
|
||||||
static void ctl_server_event_connect(struct ctl* self,
|
static void ctl_server_event_connect(struct ctl* self,
|
||||||
enum event_type evt_type,
|
enum event_type evt_type,
|
||||||
const char* client_id,
|
const struct ctl_server_client_info *info,
|
||||||
const char* client_hostname,
|
|
||||||
const char* client_username,
|
|
||||||
int new_connection_count)
|
int new_connection_count)
|
||||||
{
|
{
|
||||||
json_t* params = pack_connection_event_params(client_id, client_hostname,
|
json_t* params =
|
||||||
client_username, new_connection_count);
|
pack_connection_event_params(info, new_connection_count);
|
||||||
ctl_server_enqueue_event(self, evt_type, params);
|
ctl_server_enqueue_event(self, evt_type, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctl_server_event_connected(struct ctl* self,
|
void ctl_server_event_connected(struct ctl* self,
|
||||||
const char* client_id,
|
const struct ctl_server_client_info *info,
|
||||||
const char* client_hostname,
|
|
||||||
const char* client_username,
|
|
||||||
int new_connection_count)
|
int new_connection_count)
|
||||||
{
|
{
|
||||||
ctl_server_event_connect(self, EVT_CLIENT_CONNECTED, client_id,
|
ctl_server_event_connect(self, EVT_CLIENT_CONNECTED, info,
|
||||||
client_hostname, client_username, new_connection_count);
|
new_connection_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctl_server_event_disconnected(struct ctl* self,
|
void ctl_server_event_disconnected(struct ctl* self,
|
||||||
const char* client_id,
|
const struct ctl_server_client_info *info,
|
||||||
const char* client_hostname,
|
|
||||||
const char* client_username,
|
|
||||||
int new_connection_count)
|
int new_connection_count)
|
||||||
{
|
{
|
||||||
ctl_server_event_connect(self, EVT_CLIENT_DISCONNECTED, client_id,
|
ctl_server_event_connect(self, EVT_CLIENT_DISCONNECTED, info,
|
||||||
client_hostname, client_username, new_connection_count);
|
new_connection_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctl_server_event_capture_changed(struct ctl* self,
|
void ctl_server_event_capture_changed(struct ctl* self,
|
||||||
|
|
28
src/main.c
28
src/main.c
|
@ -1034,12 +1034,14 @@ static void on_nvnc_client_cleanup(struct nvnc_client* client)
|
||||||
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
|
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
|
||||||
self->nr_clients);
|
self->nr_clients);
|
||||||
|
|
||||||
char id[64];
|
struct ctl_server_client_info info = {
|
||||||
snprintf(id, sizeof(id), "%u", wayvnc_client->id);
|
.id = wayvnc_client->id,
|
||||||
ctl_server_event_disconnected(self->ctl, id,
|
.hostname = nvnc_client_get_hostname(client),
|
||||||
nvnc_client_get_hostname(client),
|
.username = nvnc_client_get_auth_username(client),
|
||||||
nvnc_client_get_auth_username(client),
|
.seat = wayvnc_client->seat->name,
|
||||||
self->nr_clients);
|
};
|
||||||
|
|
||||||
|
ctl_server_event_disconnected(self->ctl, &info, self->nr_clients);
|
||||||
|
|
||||||
if (self->nr_clients == 0) {
|
if (self->nr_clients == 0) {
|
||||||
nvnc_log(NVNC_LOG_INFO, "Stopping screen capture");
|
nvnc_log(NVNC_LOG_INFO, "Stopping screen capture");
|
||||||
|
@ -1067,12 +1069,14 @@ static void on_nvnc_client_new(struct nvnc_client* client)
|
||||||
nvnc_log(NVNC_LOG_DEBUG, "Client connected, new client count: %d",
|
nvnc_log(NVNC_LOG_DEBUG, "Client connected, new client count: %d",
|
||||||
self->nr_clients);
|
self->nr_clients);
|
||||||
|
|
||||||
char id[64];
|
struct ctl_server_client_info info = {
|
||||||
snprintf(id, sizeof(id), "%u", wayvnc_client->id);
|
.id = wayvnc_client->id,
|
||||||
ctl_server_event_connected(self->ctl, id,
|
.hostname = nvnc_client_get_hostname(client),
|
||||||
nvnc_client_get_hostname(client),
|
.username = nvnc_client_get_auth_username(client),
|
||||||
nvnc_client_get_auth_username(client),
|
.seat = wayvnc_client->seat->name,
|
||||||
self->nr_clients);
|
};
|
||||||
|
|
||||||
|
ctl_server_event_connected(self->ctl, &info, self->nr_clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_keyboard_option(struct wayvnc* self, const char* arg)
|
void parse_keyboard_option(struct wayvnc* self, const char* arg)
|
||||||
|
|
Loading…
Reference in New Issue