To implement a VNC server, you interact with the nvnc structure. This structure acts as the central controller for the server instance, managing sockets, connected clients, displays, and user-provided callback functions for handling input and clipboard operations.
Key responsibilities managed via the nvnc struct include:
- Input Handling: Providing callbacks for keys (
key_fn), key codes (key_code_fn), and pointer movements (pointer_fn, normalised_pointer_fn). - Clipboard: Managing cut text via
cut_text_fn and handling external clipboard messages. - Client Management: Using
new_client_fn to handle new connections. - Display Management: Managing multiple displays via the
displays array and desktop_layout_fn. - Security: Configuring authentication via
auth_fn and defining supported security_types.
/* Example of the nvnc struct members used for server implementation */
struct nvnc {
void* userdata;
nvnc_cleanup_fn cleanup_fn;
// ... input callbacks
nvnc_key_fn key_fn;
nvnc_key_fn key_code_fn;
nvnc_pointer_fn pointer_fn;
nvnc_normalised_pointer_fn normalised_pointer_fn;
// ... client and clipboard callbacks
nvnc_client_fn new_client_fn;
nvnc_cut_text_fn cut_text_fn;
// ... display and security
nvnc_desktop_layout_fn desktop_layout_fn;
struct nvnc_display* displays[NVNC_FB_COMPOSITE_MAX];
nvnc_auth_fn auth_fn;
void* auth_ud;
enum rfb_security_type security_types[MAX_SECURITY_TYPES];
};