diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-05-14 07:43:07 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2018-05-23 18:18:16 +0200 |
commit | 6da4548f0e7ccaf2b3271c0b0d59b5c8869792a7 (patch) | |
tree | 7a6e50a3e6ecff85882d91f0a503a212312ee334 /src/nvim/msgpack_rpc/channel.c | |
parent | f1bc152fa081f5d630ea1a027aa5bd00bdbb78f0 (diff) | |
download | rneovim-6da4548f0e7ccaf2b3271c0b0d59b5c8869792a7.tar.gz rneovim-6da4548f0e7ccaf2b3271c0b0d59b5c8869792a7.tar.bz2 rneovim-6da4548f0e7ccaf2b3271c0b0d59b5c8869792a7.zip |
api: list information about all channels/jobs.
Fire autocmd when channel opens or its info changes.
Add a way for API clients can describe themselves.
Diffstat (limited to 'src/nvim/msgpack_rpc/channel.c')
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 32781cf4d9..26b84b7cc7 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -61,6 +61,7 @@ void rpc_start(Channel *channel) rpc->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE); rpc->subscribed_events = pmap_new(cstr_t)(); rpc->next_request_id = 1; + rpc->info = (Dictionary)ARRAY_DICT_INIT; kv_init(rpc->call_stack); if (channel->streamtype != kChannelStreamInternal) { @@ -553,6 +554,7 @@ void rpc_free(Channel *channel) pmap_free(cstr_t)(channel->rpc.subscribed_events); kv_destroy(channel->rpc.call_stack); + api_free_dictionary(channel->rpc.info); } static bool is_rpc_response(msgpack_object *obj) @@ -642,6 +644,23 @@ static WBuffer *serialize_response(uint64_t channel_id, return rv; } +void rpc_set_client_info(uint64_t id, Dictionary info) +{ + Channel *chan = find_rpc_channel(id); + if (!chan) { + abort(); + } + + api_free_dictionary(chan->rpc.info); + chan->rpc.info = info; + channel_info_changed(chan, false); +} + +Dictionary rpc_client_info(Channel *chan) +{ + return copy_dictionary(chan->rpc.info); +} + #if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL #define REQ "[request] " #define RES "[response] " |