Last active
October 16, 2015 06:34
-
-
Save NorioKobota/fe4c5eac77de4bf8d549 to your computer and use it in GitHub Desktop.
exchange binary data between C++ and JavaScript by using linear-rpc - JS part(html)
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
<!-- | |
$ git clone --recursive https://github.com/linear-rpc/linear-js /path/to | |
$ cp /path/to/linear-js/src/linear.min.js . | |
$ cp /this/index.html ./index.html | |
$ open ./index.html # with browser | |
==> check developer console | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>exchange binary data between C++ and JavaScript by using linear-rpc</title> | |
<script type="text/javascript" src="./linear.min.js"></script> | |
<script type="text/javascript"> | |
window.onload = function() { | |
var transport = {type: "websocket", host: "127.0.0.1", port: 37800}; | |
var client = new linear.client({transports: [transport]}); | |
client.onconnect = function() { | |
client.request({method: "getBinary", params: [], | |
onresponse: function(response) { | |
var arrayBuffer = linear.tobinary(response.result); | |
var uint8ArrayBufferView = new Uint8Array(arrayBuffer); | |
console.log(uint8ArrayBufferView); | |
} | |
}); | |
}; | |
client.connect(); | |
}; | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment