blob: 9b76e0f479283c43fa9b9828dcc115f89a91aab1 [file] [log] [blame]
Meki Cherkaoui8f173612012-06-06 01:05:40 -07001<?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 Thompson7ed5ef52012-08-26 11:28:48 -07008 <script type="text/javascript" src="../java_socket_bridge.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -07009
Jeff Thompson38422f42012-11-15 00:20:39 -080010 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070011
12 <script type="text/javascript">
13 function run(){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070014 //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 Thompsonf3bd3592012-09-29 23:25:30 -070029 //var co = queryPrefix( Name );
Meki Cherkaoui8f173612012-06-06 01:05:40 -070030 console.log('HEX IS');
31 console.log(hex);
32
jeff9a9fff22012-09-23 15:45:22 -070033 var result = get('127.0.0.1', 9695, hex);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070034
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 Thompson86aea882012-09-29 17:32:48 -070071 co.from_ccnb(decoder);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070072
73 if(LOG>2) console.log(co);
74
jeff9a9fff22012-09-23 15:45:22 -070075 output += contentObjectToHtml(co);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070076 }
77 document.getElementById('result').innerHTML = output;
78 }
79
80 </script>
81
82</head>
83<body >
84 <form>
jeff9a9fff22012-09-23 15:45:22 -070085 Please Enter a Hex Encoded Interest:<br /><input id="contentname" type="text" name="CONTENTNAME" value="01d2f20002d28e310000" /> <br />
Meki Cherkaoui8f173612012-06-06 01:05:40 -070086 </form>
87 <button onclick="run()">Request Data!</button>
88 <div >
Jeff Thompson67439692012-08-26 12:15:08 -070089 <applet id="JavaSocketBridge" archive="../JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
Meki Cherkaoui8f173612012-06-06 01:05:40 -070090 </applet>
91 </div>
92
93 <p id="result"></p>
94
95</body>
jeff9a9fff22012-09-23 15:45:22 -070096</html>