diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-07-16 23:10:22 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-07-17 00:19:55 -0300 |
commit | 9d8d2b7fa83fd69d1d616728c505a41acf8fedbb (patch) | |
tree | a15cd8f07ce4aad933781c1fe80fea5f79a46a97 /src/nvim/event/socket.h | |
parent | ac2bd0256183fe4255e5fcccf37f860f037d43a6 (diff) | |
download | rneovim-9d8d2b7fa83fd69d1d616728c505a41acf8fedbb.tar.gz rneovim-9d8d2b7fa83fd69d1d616728c505a41acf8fedbb.tar.bz2 rneovim-9d8d2b7fa83fd69d1d616728c505a41acf8fedbb.zip |
server: Extract most logic into the new socket abstraction
- Move event loop code into event/socket
- Reimplement server.c on top of the new SocketWatcher class
- Adapt msgpack_rpc/channel.c
Diffstat (limited to 'src/nvim/event/socket.h')
-rw-r--r-- | src/nvim/event/socket.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/nvim/event/socket.h b/src/nvim/event/socket.h new file mode 100644 index 0000000000..17fd39f33b --- /dev/null +++ b/src/nvim/event/socket.h @@ -0,0 +1,38 @@ +#ifndef NVIM_EVENT_SOCKET_H +#define NVIM_EVENT_SOCKET_H + +#include <uv.h> + +#include "nvim/event/loop.h" +#include "nvim/event/rstream.h" +#include "nvim/event/wstream.h" + +#define ADDRESS_MAX_SIZE 256 + +typedef struct socket_watcher SocketWatcher; +typedef void (*socket_cb)(SocketWatcher *watcher, int result, void *data); +typedef void (*socket_close_cb)(SocketWatcher *watcher, void *data); + +struct socket_watcher { + // Pipe/socket path, or TCP address string + char addr[ADDRESS_MAX_SIZE]; + // TCP server or unix socket (named pipe on Windows) + union { + struct { + uv_tcp_t handle; + struct sockaddr_in addr; + } tcp; + struct { + uv_pipe_t handle; + } pipe; + } uv; + uv_stream_t *stream; + void *data; + socket_cb cb; + socket_close_cb close_cb; +}; + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "event/socket.h.generated.h" +#endif +#endif // NVIM_EVENT_SOCKET_H |