1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-22 11:01:48 +03:00
kakoune/src/remote.hh

66 lines
1.4 KiB
C++
Raw Normal View History

#ifndef remote_hh_INCLUDED
#define remote_hh_INCLUDED
2014-11-13 00:27:07 +03:00
#include "coord.hh"
#include "env_vars.hh"
2014-11-13 00:27:07 +03:00
#include "exception.hh"
#include "user_interface.hh"
#include "utils.hh"
#include <memory>
namespace Kakoune
{
struct peer_disconnected {};
struct connection_failed : runtime_error
{
connection_failed(StringView filename)
: runtime_error{"connect to " + filename + " failed"}
{}
};
2014-11-05 16:57:12 +03:00
class FDWatcher;
// A remote client handle communication between a client running on the server
// and a user interface running on the local process.
class RemoteClient
{
public:
2014-11-05 16:57:12 +03:00
RemoteClient(StringView session, std::unique_ptr<UserInterface>&& ui,
const EnvVarMap& env_vars, StringView init_command);
private:
void process_available_messages();
void process_next_message();
void write_next_key();
std::unique_ptr<UserInterface> m_ui;
2014-11-05 16:57:12 +03:00
std::unique_ptr<FDWatcher> m_socket_watcher;
2015-04-17 18:47:31 +03:00
CharCoord m_dimensions;
};
void send_command(StringView session, StringView command);
struct Server : public Singleton<Server>
{
Server(String session_name);
~Server();
const String& session() const { return m_session; }
2014-01-27 23:53:17 +04:00
void close_session();
private:
class Accepter;
void remove_accepter(Accepter* accepter);
String m_session;
std::unique_ptr<FDWatcher> m_listener;
2015-01-12 16:58:41 +03:00
Vector<std::unique_ptr<Accepter>> m_accepters;
};
}
#endif // remote_hh_INCLUDED