diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-20 10:53:02 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-24 13:02:24 -0300 |
commit | 09605cec03ea23e87ee285fd950a23ce8d23678d (patch) | |
tree | 19cb2d23c1c8b37fd01155fb7612191d6e3217a5 /src/nvim/os/msgpack_rpc.c | |
parent | c0b0bd07fd1bc92665be2b0e1eb6d5d9c736ddb1 (diff) | |
download | rneovim-09605cec03ea23e87ee285fd950a23ce8d23678d.tar.gz rneovim-09605cec03ea23e87ee285fd950a23ce8d23678d.tar.bz2 rneovim-09605cec03ea23e87ee285fd950a23ce8d23678d.zip |
channel/msgpack_rpc: Refactor msgpack_rpc_notification/serialize_event
- Generalize some argument names(event type -> event name,
event data -> event arg)
- Rename serialize_event to serialize_message
- Rename msgpack_rpc_notification to msgpack_rpc_message
- Extract the message type out of msgpack_rpc_message
- Add 'id' parameter to msgpack_rpc_message/serialize_message to create messages
that are not notifications
Diffstat (limited to 'src/nvim/os/msgpack_rpc.c')
-rw-r--r-- | src/nvim/os/msgpack_rpc.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/nvim/os/msgpack_rpc.c b/src/nvim/os/msgpack_rpc.c index 63e1245028..0d9a7ae3de 100644 --- a/src/nvim/os/msgpack_rpc.c +++ b/src/nvim/os/msgpack_rpc.c @@ -115,13 +115,22 @@ void msgpack_rpc_call(uint64_t id, msgpack_object *req, msgpack_packer *res) msgpack_rpc_dispatch(id, req, res); } -void msgpack_rpc_notification(String type, Object data, msgpack_packer *pac) +void msgpack_rpc_message(int type, + uint64_t id, + String method, + Object arg, + msgpack_packer *pac) { - msgpack_pack_array(pac, 3); - msgpack_pack_int(pac, 2); - msgpack_pack_raw(pac, type.size); - msgpack_pack_raw_body(pac, type.data, type.size); - msgpack_rpc_from_object(data, pac); + msgpack_pack_array(pac, id ? 4 : 3); + msgpack_pack_int(pac, type); + + if (id) { + msgpack_pack_uint64(pac, id); + } + + msgpack_pack_raw(pac, method.size); + msgpack_pack_raw_body(pac, method.data, method.size); + msgpack_rpc_from_object(arg, pac); } void msgpack_rpc_error(char *msg, msgpack_packer *res) |