Jeff Thompson | 287a318 | 2012-11-11 18:12:20 -0800 | [diff] [blame^] | 1 | <?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();
|
| 14 | ndn.connectWebSocket();
|
| 15 |
|
| 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() {
|
| 38 | ndn.expressInterestWS(document.getElementById('interest').value, new AsyncGetClosure(), null);
|
| 39 | }
|
| 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>
|