- 1 名前:デフォルトの名無しさん [03/01/26 20:35]
- P2Pの標準プロトコルを目指す Jxtaについてみんなでお勉強スレッドです。
初心者歓迎!質問歓迎! 関連ページ: www.wakhok.ac.jp/~maruyama/jxta/ www.atmarkit.co.jp/fjava/rensai/jxta01/jxta01_1.html www.atmarkit.co.jp/fjava/special/jxta01/jxta01_1.html www.janit.com/TechnoInf/Java/JXTA/JXTAPart1.html
- 205 名前:デフォルトの名無しさん mailto:sage [04/10/27 20:06:42]
- public class PipeTest {
private PeerGroup peerGroup = null; private PipeAdvertisement pipeAdv = null; private boolean initialized = false; private InputPipe inputPipe = null; private OutputPipe outputPipe = null; public void initializeJXTA() throws PeerGroupException { peerGroup = PeerGroupFactory.newNetPeerGroup(); } public void startTest(){ pipeAdv = (PipeAdvertisement) AdvertisementFactory.newAdvertisement( PipeAdvertisement.getAdvertisementType()); pipeAdv.setName("Pipe for PipeStreamTest"); pipeAdv.setPipeID((ID) IDFactory.newPipeID( peerGroup.getPeerGroupID())); pipeAdv.setType(PipeService.UnicastType); Server sv = new Server(); Client cl = new Client(); sv.start(); cl.start(); try { sv.join(); cl.join(); } catch ( InterruptedException e) {} }
- 206 名前:デフォルトの名無しさん mailto:sage [04/10/27 20:07:06]
- public static void main(String[] args) {
PipeTest test = new PipeTest(); try { test.initializeJXTA(); test.startTest(); } catch (Exception e) { e.printStackTrace(); } } public class Server extends Thread implements PipeMsgListener { JxtaBiDiPipe pipe; public void run() { try { JxtaServerPipe server = new JxtaServerPipe(peerGroup, pipeAdv); pipe = server.accept(); pipe.setListener(this); } catch (IOException e) {e.printStackTrace(); } try { sleep(100000); } catch (InterruptedException e) {} } public void pipeMsgEvent(PipeMsgEvent event) { Message msg = event.getMessage(); System.out.println("Server: " + msg.getMessageElement("test").toString()); try { pipe.sendMessage(msg); } catch (IOException e) { e.printStackTrace(); } } }
|

|