On Sun, 7 Feb 2016, Bram Moolenaar wrote:
A ch_status() or something like it that returns a dictionary of
info about the channel would be useful. For example, it could
indicate the mode, callback, waittime, last message number
sent/received, etc. and if the channel is dead it could just return
an empty dictionary.
We can have other functions to get the mode and timeout, although in
most cases you would already know.
Not sure why you would want statistics. For debugging? I plan to
add a log file for that.
It's surprising what users might find useful, so if it's not costly in
terms of code maintenance it might make sense to provide the
functionality. The reason I suggested a single function returning a
dictionary is that it's extendable without having to add new functions
or breaking people's Vim code.
Also, the channel callback can be invoked when the channel closes.
Currently it's only called when nothing else handles the received
message. Perhaps it's more useful to have a separate "close
callback" or "error callback".
Either way is fine with me, as long as it's possible to distinguish an
intentionally closed channel from an unexpectedly closed channel.
The other thing I noticed is that even though it says in the
documentation that you can specify a callback in ch_open, it
doesn't actually call the callback [...] I'm assuming it's just not
implemented yet
It is implemented, but it is only invoked when the sequence number
is zero.
I should have realized that, since I'm using the feature while somehow
missing how it works. Perhaps a note in the documentation is in
order.
I'm not sure how useful it is to retry opening the channel in the
background. If the channel closes unexpectedly, I would think Vim
needs to do something (e.g., restart the server).
[...]
Anyway, a blocking wait can be annoying. Retrying the connection
(with zero timeout) in the main loop might be usefel.
I think you have a point. If a retry loop makes sense in either
context the user can easily implement one in VimL.
- Christian
--
The road to success is always under construction.
Christian J. Robinson <[email protected]> http://christianrobinson.name/