diff runtime/doc/channel.txt @ 7935:3f2e0b62003d v7.4.1263

commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 5 22:36:41 2016 +0100 patch 7.4.1263 Problem: ch_open() hangs when the server isn't running. Solution: Add a timeout. Use a dict to pass arguments. (Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Fri, 05 Feb 2016 22:45:06 +0100
parents 00d64eb49ce1
children b74549818500
line wrap: on
line diff
--- a/runtime/doc/channel.txt
+++ b/runtime/doc/channel.txt
@@ -1,4 +1,4 @@
-*channel.txt*      For Vim version 7.4.  Last change: 2016 Feb 04
+*channel.txt*      For Vim version 7.4.  Last change: 2016 Feb 05
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -32,7 +32,7 @@ This requires Python.  The demo program 
 Run it in one terminal.  We will call this T1.
 
 Run Vim in another terminal.  Connect to the demo server with: >
-	let handle = ch_open('localhost:8765', 'json')
+	let handle = ch_open('localhost:8765')
 
 In T1 you should see:
 	=== socket opened === ~
@@ -62,23 +62,25 @@ To handle asynchronous communication a c
 Instead of giving a callback with every send call, it can also be specified
 when opening the channel: >
 	call ch_close(handle)
-	let handle = ch_open('localhost:8765', 'json', "MyHandler")
+	let handle = ch_open('localhost:8765', {'callback': "MyHandler"})
 	call ch_sendexpr(handle, 'hello!', 0)
 
 ==============================================================================
 2. Opening a channel					*channel-open*
 
 To open a channel: >
-    let handle = ch_open({address}, {mode}, {callback})
+    let handle = ch_open({address} [, {argdict}])
 
 {address} has the form "hostname:port".  E.g., "localhost:8765".
 
-{mode} can be:						*channel-mode*
-	"json" - Use JSON, see below; most convenient way
+{argdict} is a dictionary with optional entries:
+
+"mode" can be:						*channel-mode*
+	"json" - Use JSON, see below; most convenient way. Default.
 	"raw"  - Use raw messages
 
 							*channel-callback*
-{callback} is a function that is called when a message is received that is not
+"callback" is a function that is called when a message is received that is not
 handled otherwise.  It gets two arguments: the channel handle and the received
 message. Example: >
 	func Handle(handle, msg)
@@ -86,16 +88,28 @@ message. Example: >
 	endfunc
 	let handle = ch_open("localhost:8765", 'json', "Handle")
 
-When {mode} is "json" the "msg" argument is the body of the received message,
+"waittime" is the time to wait for the connection to be made in milliseconds.
+The default is zero, don't wait, which is useful if the server is supposed to
+be running already.  A negative number waits forever.
+
+"timeout" is the time to wait for a request when blocking, using
+ch_sendexpr().  Again in millisecons.  The default si 2000 (2 seconds).
+
+When "mode" is "json" the "msg" argument is the body of the received message,
 converted to Vim types.
-When {mode} is "raw" the "msg" argument is the whole message as a string.
+When "mode" is "raw" the "msg" argument is the whole message as a string.
 
-When {mode} is "json" the {callback} is optional.  When omitted it is only
+When "mode" is "json" the "callback" is optional.  When omitted it is only
 possible to receive a message after sending one.
 
 The handler can be added or changed later: >
     call ch_setcallback(handle, {callback})
-When {callback} is empty (zero or an empty string) the handler is removed.
+When "callback is empty (zero or an empty string) the handler is removed.
+NOT IMPLEMENTED YET
+
+The timeout can be changed later: >
+    call ch_settimeout(handle, {msec})
+NOT IMPLEMENTED YET
 
 Once done with the channel, disconnect it like this: >
     call ch_close(handle)