blob: cd19c9cd54673afe8519a1cad71f5d0f711937c9 [file] [log] [blame]
<?xml version = "1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<meta charset="UTF-8">
<head>
<title>NDN Get via WebSocket</title>
<script type="text/javascript" src="../Helper.js"></script>
<script type="text/javascript">
var ndn = new NDN({port:9696});
ndn.transport.connectWebSocket(ndn);
var AsyncGetClosure = function AsyncGetClosure() {
// Inherit from Closure.
Closure.call(this);
};
AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) {
if (kind == Closure.UPCALL_FINAL) {
// Do nothing.
} else if (kind == Closure.UPCALL_CONTENT) {
console.log("Closure.upcall() executed.");
var content = upcallInfo.contentObject;
nameStr = escape(content.name.getName());
console.log("In callback, nameStr: " + nameStr);
console.log("In callback, content: ");
console.log(content);
document.getElementById('content').innerHTML = contentObjectToHtml(content);
}
return Closure.RESULT_OK;
};
function run() {
ndn.expressInterest(new Name(document.getElementById('interest').value), new AsyncGetClosure());
}
</script>
</head>
<body >
<form>
Please Enter an Interest:<br />
<input id="interest" type="text" name="INTEREST" size="50" value="/%C1.M.S.localhost/%C1.M.SRV/ccnd/KEY" />
</form>
<button onclick="run()">Fetch Content</button>
<p id="content">Content: <br/></p>
</body>
</html>