diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 3b8deeed9..f70d24ce2 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -217,6 +217,8 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) printf("Registering Peer: %d\n", wfi->peerCount); wf_info_unlock(wfi); + + wfreerdp_server_peer_connect_event(wfi->peerCount); } } @@ -235,6 +237,8 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) #endif wf_info_unlock(wfi); + + wfreerdp_server_peer_disconnect_event(wfi->peerCount); } } diff --git a/server/Windows/wf_interface.c b/server/Windows/wf_interface.c index 59566d9fa..0ceb46012 100644 --- a/server/Windows/wf_interface.c +++ b/server/Windows/wf_interface.c @@ -42,6 +42,9 @@ struct rdp_listener }; // +cbConEvent cbConnect; +cbConEvent cbDisconnect; + DWORD WINAPI wf_server_main_loop(LPVOID lpParam) { int i, fds; @@ -148,6 +151,9 @@ wfServer* wfreerdp_server_new() server->port = 3389; } + cbConnect = NULL; + cbDisconnect = NULL; + return server; } @@ -286,3 +292,26 @@ FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId) return FALSE; } } + +FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb) +{ + cbConnect = cb; +} + +FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb) +{ + cbDisconnect = cb; +} + + +void wfreerdp_server_peer_connect_event(int pId) +{ + if (cbConnect) + cbConnect(pId); +} +void wfreerdp_server_peer_disconnect_event(int pId) +{ + if (cbDisconnect) + cbDisconnect(pId); +} + diff --git a/server/Windows/wf_interface.h b/server/Windows/wf_interface.h index 538dd210f..908b48f7a 100644 --- a/server/Windows/wf_interface.h +++ b/server/Windows/wf_interface.h @@ -86,6 +86,8 @@ struct wf_server }; typedef struct wf_server wfServer; +typedef void (__stdcall* cbConEvent) (int); + FREERDP_API BOOL wfreerdp_server_start(wfServer* server); FREERDP_API BOOL wfreerdp_server_stop(wfServer* server); @@ -101,4 +103,10 @@ FREERDP_API BOOL wfreerdp_server_peer_is_connected(int pId); FREERDP_API BOOL wfreerdp_server_peer_is_activated(int pId); FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId); +FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb); +FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb); + +void wfreerdp_server_peer_connect_event(int pId); +void wfreerdp_server_peer_disconnect_event(int pId); + #endif /* WF_INTERFACE_H */