Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [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 |
|
| 6 | <head>
|
| 7 | <title>NDN Send Hex</title>
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 8 | <script type="text/javascript" src="../java_socket_bridge.js"></script>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 9 |
|
Jeff Thompson | 38422f4 | 2012-11-15 00:20:39 -0800 | [diff] [blame] | 10 | <script type="text/javascript" src="../Helper.js"></script>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 11 |
|
| 12 | <script type="text/javascript">
|
| 13 | function run(){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 14 | //var n = a.replace("%","");
|
| 15 |
|
| 16 | //console.log(n);
|
| 17 |
|
| 18 | var hex = document.getElementById('contentname').value;
|
| 19 |
|
| 20 | ///////////////////////////////////////
|
| 21 | //createRoute(, 9695);
|
| 22 |
|
| 23 |
|
| 24 | /// /ndn/ucla.edu/apps/hydra/mainvideo
|
| 25 | //createRoute('131.179.141.15', 9695);
|
| 26 | //createRoute('borges.metwi.ucla.edu', 9695);
|
| 27 |
|
| 28 | //content object
|
Jeff Thompson | f3bd359 | 2012-09-29 23:25:30 -0700 | [diff] [blame] | 29 | //var co = queryPrefix( Name );
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 30 | console.log('HEX IS');
|
| 31 | console.log(hex);
|
| 32 |
|
jeff | 9a9fff2 | 2012-09-23 15:45:22 -0700 | [diff] [blame] | 33 | var result = get('127.0.0.1', 9695, hex);
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 34 |
|
| 35 | console.log('BINARY RESPONSE IS ' +result);
|
| 36 |
|
| 37 | var output ="";
|
| 38 | output += "HEX ANSWER IS: "+ result;
|
| 39 |
|
| 40 | output+= "<br />";
|
| 41 | output+= "<br />";
|
| 42 |
|
| 43 | //result[0] and result[1] should be 0 and 4 if there is a content object found
|
| 44 | if(result==null || result==undefined || result =="" ){
|
| 45 |
|
| 46 |
|
| 47 | if(LOG>2)console.log('INVALID ANSWER');
|
| 48 | output += "NO CONTENT FOUND";
|
| 49 |
|
| 50 | output+= "<br />";
|
| 51 | output+= "<br />";
|
| 52 | }
|
| 53 |
|
| 54 | else if(result[0] != '0'||result[1]!='4') {
|
| 55 | if(LOG>2)console.log('INVALID ANSWER');
|
| 56 | output += "INVALID ANSWER";
|
| 57 |
|
| 58 | output+= "<br />";
|
| 59 | output+= "<br />";
|
| 60 | }
|
| 61 | else{
|
| 62 |
|
| 63 | var numbers = DataUtils.toNumbers(result);
|
| 64 |
|
| 65 | console.log('HEX RESPONSE IS \n'+numbers);
|
| 66 | decoder = new BinaryXMLDecoder(numbers);
|
| 67 |
|
| 68 |
|
| 69 | co = new ContentObject();
|
| 70 |
|
Jeff Thompson | 86aea88 | 2012-09-29 17:32:48 -0700 | [diff] [blame] | 71 | co.from_ccnb(decoder);
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 72 |
|
| 73 | if(LOG>2) console.log(co);
|
| 74 |
|
jeff | 9a9fff2 | 2012-09-23 15:45:22 -0700 | [diff] [blame] | 75 | output += contentObjectToHtml(co);
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 76 | }
|
| 77 | document.getElementById('result').innerHTML = output;
|
| 78 | }
|
| 79 |
|
| 80 | </script>
|
| 81 |
|
| 82 | </head>
|
| 83 | <body >
|
| 84 | <form>
|
jeff | 9a9fff2 | 2012-09-23 15:45:22 -0700 | [diff] [blame] | 85 | Please Enter a Hex Encoded Interest:<br /><input id="contentname" type="text" name="CONTENTNAME" value="01d2f20002d28e310000" /> <br />
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 86 | </form>
|
| 87 | <button onclick="run()">Request Data!</button>
|
| 88 | <div >
|
Jeff Thompson | 6743969 | 2012-08-26 12:15:08 -0700 | [diff] [blame] | 89 | <applet id="JavaSocketBridge" archive="../JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 90 | </applet>
|
| 91 | </div>
|
| 92 |
|
| 93 | <p id="result"></p>
|
| 94 |
|
| 95 | </body>
|
jeff | 9a9fff2 | 2012-09-23 15:45:22 -0700 | [diff] [blame] | 96 | </html>
|