blob: f93db6cd9e0802bc23856fff7eff710869cc5a35 [file] [log] [blame]
Jeff Thompson287a3182012-11-11 18:12:20 -08001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
4<html xmlns = "http://www.w3.org/1999/xhtml">
5<meta charset="UTF-8">
6
7<head>
8 <title>NDN Get via WebSocket</title>
9
10 <script type="text/javascript" src="../Helper.js"></script>
11
12 <script type="text/javascript">
13 var ndn = new NDN();
Jeff Thompson5b265a72012-11-12 01:13:08 -080014 ndn.transport.connectWebSocket(ndn);
Jeff Thompson287a3182012-11-11 18:12:20 -080015
16 var AsyncGetClosure = function AsyncGetClosure() {
17 // Inherit from Closure.
18 Closure.call(this);
19 };
20
21 AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) {
22 if (kind == Closure.UPCALL_FINAL) {
23 // Do nothing.
24 } else if (kind == Closure.UPCALL_CONTENT) {
25 console.log("Closure.upcall() executed.");
26 var content = upcallInfo.contentObject;
27 nameStr = escape(content.name.getName());
28 console.log("In callback, nameStr: " + nameStr);
29 console.log("In callback, content: ");
30 console.log(content);
31 document.getElementById('content').innerHTML = contentObjectToHtml(content);
32 }
33 return Closure.RESULT_OK;
34 };
35
36
37 function run() {
Jeff Thompson5b265a72012-11-12 01:13:08 -080038 ndn.expressInterest(new Name(document.getElementById('interest').value), new AsyncGetClosure());
Jeff Thompson287a3182012-11-11 18:12:20 -080039 }
40
41 </script>
42
43</head>
44<body >
45
46 <form>
47 Please Enter an Interest:<br />
48 <input id="interest" type="text" name="INTEREST" size="50" value="/%C1.M.S.localhost/%C1.M.SRV/ccnd/KEY" />
49 </form>
50
51 <button onclick="run()">Fetch Content</button>
52
53 <p id="content">Content: <br/></p>
54
55</body>
56</html>