From 09605cec03ea23e87ee285fd950a23ce8d23678d Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 20 Jun 2014 10:53:02 -0300 Subject: 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 --- src/nvim/os/msgpack_rpc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/nvim/os/msgpack_rpc.c') 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) -- cgit