2012-10-24 00:55:44 +04:00
|
|
|
#ifndef remote_hh_INCLUDED
|
|
|
|
#define remote_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "display_buffer.hh"
|
2013-01-10 21:54:40 +04:00
|
|
|
#include "event_manager.hh"
|
2013-04-09 22:05:40 +04:00
|
|
|
#include "user_interface.hh"
|
2012-10-24 00:55:44 +04:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-10-30 17:00:44 +04:00
|
|
|
struct peer_disconnected {};
|
2012-10-26 15:45:32 +04:00
|
|
|
|
2013-03-12 21:53:18 +04:00
|
|
|
// A remote client handle communication between a client running on the server
|
|
|
|
// and a user interface running on the local process.
|
2012-10-24 00:55:44 +04:00
|
|
|
class RemoteClient
|
|
|
|
{
|
|
|
|
public:
|
2013-03-13 22:59:39 +04:00
|
|
|
RemoteClient(int socket, std::unique_ptr<UserInterface>&& ui,
|
2012-12-19 00:20:36 +04:00
|
|
|
const String& init_command);
|
2012-10-24 00:55:44 +04:00
|
|
|
|
2013-03-13 22:59:39 +04:00
|
|
|
private:
|
2012-10-24 00:55:44 +04:00
|
|
|
void process_next_message();
|
|
|
|
void write_next_key();
|
|
|
|
|
|
|
|
std::unique_ptr<UserInterface> m_ui;
|
2012-10-26 18:14:51 +04:00
|
|
|
DisplayCoord m_dimensions;
|
2013-01-11 21:44:02 +04:00
|
|
|
FDWatcher m_socket_watcher;
|
2012-10-24 00:55:44 +04:00
|
|
|
};
|
2013-03-13 22:59:39 +04:00
|
|
|
std::unique_ptr<RemoteClient> connect_to(const String& pid,
|
|
|
|
std::unique_ptr<UserInterface>&& ui,
|
|
|
|
const String& init_command);
|
|
|
|
|
|
|
|
struct Server : public Singleton<Server>
|
|
|
|
{
|
2013-09-25 22:04:52 +04:00
|
|
|
Server(String session_name);
|
2013-03-13 22:59:39 +04:00
|
|
|
~Server();
|
2013-09-25 22:04:52 +04:00
|
|
|
const String& session() const { return m_session; }
|
2013-03-13 22:59:39 +04:00
|
|
|
|
|
|
|
private:
|
2013-09-25 22:04:52 +04:00
|
|
|
String m_session;
|
2013-03-13 22:59:39 +04:00
|
|
|
std::unique_ptr<FDWatcher> m_listener;
|
|
|
|
};
|
2012-10-24 00:55:44 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // remote_hh_INCLUDED
|
|
|
|
|