mirror of
https://github.com/lxsang/antd-wvnc-plugin.git
synced 2024-12-27 04:18:22 +01:00
Only send data to client when it is ready, to save bandwidth
All checks were successful
gitea-sync/antd-wvnc-plugin/pipeline/head This commit looks good
All checks were successful
gitea-sync/antd-wvnc-plugin/pipeline/head This commit looks good
This commit is contained in:
parent
c993d8bd95
commit
a3f28280c9
16
wvnc.c
16
wvnc.c
@ -42,6 +42,7 @@ typedef struct
|
|||||||
uint16_t uy;
|
uint16_t uy;
|
||||||
uint16_t uw;
|
uint16_t uw;
|
||||||
uint16_t uh;
|
uint16_t uh;
|
||||||
|
uint8_t ready;
|
||||||
//int rate;
|
//int rate;
|
||||||
} wvnc_user_data_t;
|
} wvnc_user_data_t;
|
||||||
|
|
||||||
@ -326,8 +327,9 @@ static void finish_update(rfbClient *client)
|
|||||||
{
|
{
|
||||||
wvnc_user_data_t *user_data = get_user_data(rfbClientGetClientData(client, client));
|
wvnc_user_data_t *user_data = get_user_data(rfbClientGetClientData(client, client));
|
||||||
long long current_time = current_timestamp();
|
long long current_time = current_timestamp();
|
||||||
if(current_time - user_data->last_update < 40)
|
if(!user_data->ready)
|
||||||
{
|
{
|
||||||
|
// LOG("User is not ready");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t bytes = (uint8_t)client->format.bitsPerPixel / 8;
|
uint8_t bytes = (uint8_t)client->format.bitsPerPixel / 8;
|
||||||
@ -391,6 +393,7 @@ static void finish_update(rfbClient *client)
|
|||||||
user_data->uy = 0xFFFF;
|
user_data->uy = 0xFFFF;
|
||||||
user_data->uw = 0;
|
user_data->uw = 0;
|
||||||
user_data->uh = 0;
|
user_data->uh = 0;
|
||||||
|
user_data->ready = 0;
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +427,7 @@ static rfbCredential *get_credential(rfbClient *cl, int credentialType)
|
|||||||
while (*pass != '\0')
|
while (*pass != '\0')
|
||||||
pass++;
|
pass++;
|
||||||
pass++;
|
pass++;
|
||||||
LOG("User name %s, pass: %s\n", up, pass);
|
//LOG("User name %s, pass: %s\n", up, pass);
|
||||||
memcpy(c->userCredential.username, up, strlen(up) + 1);
|
memcpy(c->userCredential.username, up, strlen(up) + 1);
|
||||||
memcpy(c->userCredential.password, pass, strlen(pass) + 1);
|
memcpy(c->userCredential.password, pass, strlen(pass) + 1);
|
||||||
free(up);
|
free(up);
|
||||||
@ -614,10 +617,15 @@ void *consume_client(void *ptr, wvnc_cmd_t header)
|
|||||||
case 0x04: // ack from client
|
case 0x04: // ack from client
|
||||||
data = (uint8_t *)malloc(1);
|
data = (uint8_t *)malloc(1);
|
||||||
*data = (uint8_t)header.data[0];
|
*data = (uint8_t)header.data[0];
|
||||||
|
user_data->ready = 1;
|
||||||
return data;
|
return data;
|
||||||
break;
|
break;
|
||||||
case 0x05: //mouse event
|
case 0x05: //mouse event
|
||||||
//LOG("MOuse event %d\n", header.data[4]);
|
LOG(
|
||||||
|
"MOuse event received at (%d,%d) Buton mask %d\n",
|
||||||
|
(header.data[0] | (header.data[1] << 8)) & 0xFFFF,
|
||||||
|
(header.data[2] | (header.data[3] << 8)) & 0xFFFF,
|
||||||
|
header.data[4]);
|
||||||
SendPointerEvent(user_data->vncl,
|
SendPointerEvent(user_data->vncl,
|
||||||
(header.data[0] | (header.data[1] << 8)) & 0xFFFF,
|
(header.data[0] | (header.data[1] << 8)) & 0xFFFF,
|
||||||
(header.data[2] | (header.data[3] << 8)) & 0xFFFF, header.data[4]);
|
(header.data[2] | (header.data[3] << 8)) & 0xFFFF, header.data[4]);
|
||||||
@ -651,7 +659,7 @@ static void got_clipboard(rfbClient *cl, const char *text, int len)
|
|||||||
uint8_t *ack = (uint8_t *)process(user_data, 1);
|
uint8_t *ack = (uint8_t *)process(user_data, 1);
|
||||||
if (!ack || !(*ack))
|
if (!ack || !(*ack))
|
||||||
{
|
{
|
||||||
LOG("Fail to set client clipboard");
|
ERROR("Fail to set client clipboard");
|
||||||
if (ack)
|
if (ack)
|
||||||
free(ack);
|
free(ack);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user