<Peer>node1</Peer> <KeyWords>Netpeer group by default</Keywords> <PeerId> jxta://59616261646162614A78746150325033DB1EB6636DCE4B2990CA888B36CD96C7000 0000000000000000000000000000000000000000000000000000000000301 </PeerId> <TransportAddress>tcp://169.254.101.152:9700/</TransportAddress>
-f 開關是必須的。它表示緊接在后面的是一個文件名;這個用法跟 UNIX 的 tar 命令相似。省略它將導致未定義的行為,包括異常!
現在,將導入的文件作為一個標記值(與名為 dwTag 的標記聯系在一起)附加到消息上。從概念上說,我們是在把屬性附加到消息對象中。屬性將與消息一起通過管道傳送并可在另一端將它拆離。在下層,一個額外的 XML 片段被插入到結構化文檔(消息)中,它包含附加文檔,并以標記值命名;相關的報頭也被修改以反映新的、更大的大小。用 put 命令就可以完成這一切。稍后,可以用 get 命令從消息中抽取相同的標記值,get 命令通過逆向進行上述過程找回所導入的文件。
try { myInpStream = myMesg.pop (tagName); println("tagName used is " + tagName); myStructDoc = StructuredDocumentFactory.newStructuredDocument ( new MimeMediaType ("text/xml"), myInpStream); OutputStream out = new ByteArrayOutputStream();
myStructDoc.sendToStream( out ); println("received a message..."); print ( out.toString() ); } catch (Exception e) { println("waitptext: failed in messge receive"); return ShellApp.appMiscError; } return ShellApp.appNoError; }
JXTA>waitptext dwTag created a pipe advertisement... created an input pipe based on the advertisement... published the pipe advertisement to the group... waiting at the input pipe for a message...
tagName used is dwTag received a message... <?xml version="1.0"?> <ShellDoc> <Item> This is a simple file for Jxta transfer. It can contain anything. </Item> </ShellDoc> JXTA>