Mercurial > hg > FederatedLinda
view src/fdl/test/metaTransfer/MetaProtocolEngine_not.java @ 53:629b6cfbd37f
metaprotocol ring
author | axmo |
---|---|
date | Mon, 19 Jan 2009 17:49:14 +0900 |
parents | |
children | 82a292aa41ad |
line wrap: on
line source
package fdl.test.metaTransfer; import java.io.IOException; import java.nio.ByteBuffer; import fdl.FederatedLinda; import fdl.MetaEngine; //import fdl.MetaReply; import fdl.MetaLinda; import fdl.PSXLinda; import fdl.PSXReply; public class MetaProtocolEngine_not implements MetaEngine { private FederatedLinda fdlmeta; private ByteBuffer data = ByteBuffer.allocate(1024); private int id = 10; private boolean running = true; //ここからsend用宣言 private PSXLinda sendpsx,getpsx; private String host = "127.0.0.1"; private int port; public MetaProtocolEngine_not(MetaLinda fdlmeta, int port) { this.port = port; } public void metaOpen(int sendport){ try{ sendpsx = fdlmeta.open(host, sendport); }catch (IOException e) { e.printStackTrace(); } } //meta部分のデータ取得 public void metaTrans() { try { getpsx = fdlmeta.open(host, 10001); } catch (IOException e) { e.printStackTrace(); } PSXReply in = getpsx.in(id); while (running) { System.out.println(in); System.out.println(in.ready()); if(in.ready()) { data = in.getData(); sendpsx.out(id, data); running = false; break; } } } public void mainLoop() { System.out.println("MetaProtocolEngine Start"); fdlmeta = FederatedLinda.init(); if( port == 10002 ) { metaOpen(10003); metaTrans(); try { fdlmeta.sync(); } catch (IOException e) { e.printStackTrace(); } System.out.println("MetaProtocolEngine Connect"); } } }