Last active
October 22, 2016 17:03
-
-
Save prabirshrestha/1c9e884ad13bd83c1ad7 to your computer and use it in GitHub Desktop.
async vim with channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:Handler(handle, msg) | |
echom a:handle | |
echom a:msg | |
endfunction | |
let handle = ch_open('localhost:8000', {'mode': 'json'}) | |
call ch_sendexpr(handle, 'hello', function('s:Handler')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
net.createServer(function(socket){ | |
socket.on('data', function(data){ | |
var request = JSON.parse(data); | |
console.log('received', request); | |
setTimeout(function () { | |
var response = [ | |
request[0], | |
request[1] | |
]; | |
console.log('sending', response); | |
socket.write(JSON.stringify(response)); | |
}, 2000); | |
}); | |
}).listen(8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment