editor_file_server.h 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef EDITOR_FILE_SERVER_H
  2. #define EDITOR_FILE_SERVER_H
  3. #include "object.h"
  4. #include "os/thread.h"
  5. #include "io/tcp_server.h"
  6. #include "io/packet_peer.h"
  7. #include "io/file_access_network.h"
  8. class EditorFileServer : public Object {
  9. OBJ_TYPE(EditorFileServer,Object);
  10. enum Command {
  11. CMD_NONE,
  12. CMD_ACTIVATE,
  13. CMD_STOP,
  14. };
  15. struct ClientData {
  16. Thread *thread;
  17. Ref<StreamPeerTCP> connection;
  18. Map<int,FileAccess*> files;
  19. EditorFileServer *efs;
  20. bool quit;
  21. };
  22. Ref<TCP_Server> server;
  23. Set<Thread*> to_wait;
  24. static void _close_client(ClientData *cd);
  25. static void _subthread_start(void*s);
  26. Mutex *wait_mutex;
  27. Thread *thread;
  28. static void _thread_start(void*);
  29. bool quit;
  30. Command cmd;
  31. String password;
  32. int port;
  33. bool active;
  34. public:
  35. void start();
  36. void stop();
  37. bool is_active() const;
  38. EditorFileServer();
  39. ~EditorFileServer();
  40. };
  41. #endif // EDITOR_FILE_SERVER_H