wfreerdp-server: added connect/disconnect event callback support

This commit is contained in:
Corey C 2012-10-05 23:25:18 -04:00
parent 8074b0b842
commit a2cd04e3f7
3 changed files with 41 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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 */