task.h 705 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef __TASK_H
  2. #define __TASK_H
  3. #include "chatclient.h"
  4. // A task is something that needs to be done that will take a while.
  5. // Tasks are done in a separate thread if websocket.run_async is true.
  6. class task
  7. {
  8. public:
  9. task();
  10. bool started;
  11. bool finished;
  12. bool running_async;
  13. void closeconnection(chatclient *client,bool run_async);
  14. void receivedmessage(chatclient *client,message *new_message,bool run_async);
  15. void dotask();
  16. private:
  17. enum task_type
  18. {
  19. close_connection = 1,
  20. received_message = 2
  21. };
  22. task_type _task_type;
  23. chatclient *_client;
  24. message *_message;
  25. void initialize_task(task_type tasktype,bool run_async);
  26. void closeconnection();
  27. void receivedmessage();
  28. };
  29. #endif