blob: 4ccac105287e6a9b470409143285aad3b26a7b27 [file] [log] [blame]
Jeff Thompson202728a2013-02-10 22:20:08 -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<!--
5 See COPYING for copyright and distribution information.
6-->
7<html xmlns = "http://www.w3.org/1999/xhtml">
8<meta charset="UTF-8"/>
9
10<head>
11 <title>NDN PIT Matching</title>
12
13 <script type="text/javascript" src="../Helper.js"></script>
14
15 <script type="text/javascript">
16 var ndn = new NDN({verify:false});
17
18 var AsyncGetClosure = function AsyncGetClosure(target) {
19 // Inherit from Closure.
20 Closure.call(this);
21
22 this.target = target;
23 };
24
25 AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) {
26 if (kind == Closure.UPCALL_CONTENT || kind == Closure.UPCALL_CONTENT_UNVERIFIED) {
27 document.getElementById(this.target).innerHTML =
28 DataUtils.toString(upcallInfo.contentObject.content);
29 return Closure.RESULT_OK;
30 }
31 else
32 return Closure.RESULT_ERR;
33 };
34
35 var name = new Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt");
36
37 var interestSelector1 = new Interest();
38 interestSelector1.interestLifetime = 10000;
39 interestSelector1.minSuffixComponents = 3;
40 interestSelector1.maxSuffixComponents = 3;
41
42 var interestSelector2 = new Interest();
43 interestSelector2.interestLifetime = 10000;
44 interestSelector2.minSuffixComponents = 4;
45 interestSelector2.maxSuffixComponents = 4;
46
47 var interestSelector3 = new Interest();
48 interestSelector3.interestLifetime = 10000;
49 interestSelector3.exclude = new Exclude([Exclude.ANY, DataUtils.toNumbersFromString("zzzzzz")]);
50
51 var interestSelector4 = new Interest();
52 interestSelector4.interestLifetime = 10000;
53 interestSelector4.exclude = new Exclude([DataUtils.toNumbersFromString("zzzzzz"), Exclude.ANY]);
54
55 function run() {
56 ndn.onopen = function() {
57 for (var i = 0; i < 10; ++i) {
58 // "col1Content0" is already fetched.
59 if (i != 0)
60 ndn.expressInterest(name, new AsyncGetClosure("col1Content" + i), interestSelector1);
61 ndn.expressInterest(name, new AsyncGetClosure("col2Content" + i), interestSelector2);
62 ndn.expressInterest(name, new AsyncGetClosure("col3Content" + i), interestSelector3);
63 ndn.expressInterest(name, new AsyncGetClosure("col4Content" + i), interestSelector4);
64 }
65 // For testing, make sure we don't just process in the order returned.
66 DataUtils.shuffle(NDN.PITTable);
67 };
68
69 ndn.expressInterest(name, new AsyncGetClosure("col1Content0"), interestSelector1);
70 }
71 </script>
72</head>
73<body >
74 <button id="runBtn" onclick="run()">Run</button>
75 <table style="text-align: left;" border="1" cellpadding="2" cellspacing="0">
76 <tbody>
77 <tr>
78 <td style="vertical-align: top;">minSuffixComponents=3,<br/>maxSuffixComponents=3<br/>should be:<br/>
79 hello</td>
80 <td style="vertical-align: top;">minSuffixComponents=4,<br/>maxSuffixComponents=4<br/>should be:<br/>
81 hello world</td>
82 <td style="vertical-align: top;">exclude=*,zzzzzz<br/><br/>should be:<br/>hello</td>
83 <td style="vertical-align: top;">exclude=zzzzzz,*<br/><br/>should be:<br/>hello world</td>
84 </tr>
85 <tr>
86 <td style="vertical-align: top;"><div id="col1Content0"/></td>
87 <td style="vertical-align: top;"><div id="col2Content0"/></td>
88 <td style="vertical-align: top;"><div id="col3Content0"/></td>
89 <td style="vertical-align: top;"><div id="col4Content0"/></td>
90 </tr>
91 <tr>
92 <td style="vertical-align: top;"><div id="col1Content1"/></td>
93 <td style="vertical-align: top;"><div id="col2Content1"/></td>
94 <td style="vertical-align: top;"><div id="col3Content1"/></td>
95 <td style="vertical-align: top;"><div id="col4Content1"/></td>
96 </tr>
97 <tr>
98 <td style="vertical-align: top;"><div id="col1Content2"/></td>
99 <td style="vertical-align: top;"><div id="col2Content2"/></td>
100 <td style="vertical-align: top;"><div id="col3Content2"/></td>
101 <td style="vertical-align: top;"><div id="col4Content2"/></td>
102 </tr>
103 <tr>
104 <td style="vertical-align: top;"><div id="col1Content3"/></td>
105 <td style="vertical-align: top;"><div id="col2Content3"/></td>
106 <td style="vertical-align: top;"><div id="col3Content3"/></td>
107 <td style="vertical-align: top;"><div id="col4Content3"/></td>
108 </tr>
109 <tr>
110 <td style="vertical-align: top;"><div id="col1Content4"/></td>
111 <td style="vertical-align: top;"><div id="col2Content4"/></td>
112 <td style="vertical-align: top;"><div id="col3Content4"/></td>
113 <td style="vertical-align: top;"><div id="col4Content4"/></td>
114 </tr>
115 <tr>
116 <td style="vertical-align: top;"><div id="col1Content5"/></td>
117 <td style="vertical-align: top;"><div id="col2Content5"/></td>
118 <td style="vertical-align: top;"><div id="col3Content5"/></td>
119 <td style="vertical-align: top;"><div id="col4Content5"/></td>
120 </tr>
121 <tr>
122 <td style="vertical-align: top;"><div id="col1Content6"/></td>
123 <td style="vertical-align: top;"><div id="col2Content6"/></td>
124 <td style="vertical-align: top;"><div id="col3Content6"/></td>
125 <td style="vertical-align: top;"><div id="col4Content6"/></td>
126 </tr>
127 <tr>
128 <td style="vertical-align: top;"><div id="col1Content7"/></td>
129 <td style="vertical-align: top;"><div id="col2Content7"/></td>
130 <td style="vertical-align: top;"><div id="col3Content7"/></td>
131 <td style="vertical-align: top;"><div id="col4Content7"/></td>
132 </tr>
133 <tr>
134 <td style="vertical-align: top;"><div id="col1Content8"/></td>
135 <td style="vertical-align: top;"><div id="col2Content8"/></td>
136 <td style="vertical-align: top;"><div id="col3Content8"/></td>
137 <td style="vertical-align: top;"><div id="col4Content8"/></td>
138 </tr>
139 <tr>
140 <td style="vertical-align: top;"><div id="col1Content9"/></td>
141 <td style="vertical-align: top;"><div id="col2Content9"/></td>
142 <td style="vertical-align: top;"><div id="col3Content9"/></td>
143 <td style="vertical-align: top;"><div id="col4Content9"/></td>
144 </tr>
145 </tbody>
146 </table>
147</body>
148</html>