ifc_authcallback.h 820 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. #include <windows.h> //need this for Sleep()
  4. class ifc_authcallback : public Dispatchable
  5. {
  6. protected:
  7. ifc_authcallback() {}
  8. ~ifc_authcallback() {}
  9. public:
  10. int OnConnecting();
  11. int OnSending();
  12. int OnReceiving();
  13. // pump your message loop for a little while
  14. int OnIdle();
  15. enum
  16. {
  17. ONCONNECTING=0,
  18. ONSENDING=1,
  19. ONRECEIVING=2,
  20. ONIDLE=3,
  21. };
  22. };
  23. inline int ifc_authcallback::OnConnecting()
  24. {
  25. return _call(ONCONNECTING, (int)0);
  26. }
  27. inline int ifc_authcallback::OnSending()
  28. {
  29. return _call(ONSENDING, (int)0);
  30. }
  31. inline int ifc_authcallback::OnReceiving()
  32. {
  33. return _call(ONRECEIVING, (int)0);
  34. }
  35. inline int ifc_authcallback::OnIdle()
  36. {
  37. int retval;
  38. if (_dispatch(ONIDLE, &retval))
  39. return retval;
  40. else
  41. {
  42. // default implementation
  43. Sleep(50);
  44. return 0;
  45. }
  46. }