Put this code at the end of your main function before return.
unsigned int bRet = -1;
MSG msg;
while ((bRet = GetMessage(&msg, nullptr, 0, 0)) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Explanation of this logic has already provided here: joinSession Event callbacks are not fired - #11 by mtaha
Hope this will work for you.