53
|
1 package fdl.test.metaTransfer;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.nio.ByteBuffer;
|
|
5
|
|
6 import fdl.FederatedLinda;
|
|
7 import fdl.MetaEngine;
|
|
8 //import fdl.MetaReply;
|
|
9 import fdl.MetaLinda;
|
|
10 import fdl.PSXLinda;
|
|
11 import fdl.PSXReply;
|
|
12
|
|
13
|
|
14 public class MetaProtocolEngine_not implements MetaEngine {
|
|
15 private FederatedLinda fdlmeta;
|
|
16 private ByteBuffer data = ByteBuffer.allocate(1024);
|
|
17 private int id = 10;
|
|
18 private boolean running = true;
|
|
19
|
|
20 //ここからsend用宣言
|
|
21 private PSXLinda sendpsx,getpsx;
|
|
22 private String host = "127.0.0.1";
|
|
23 private int port;
|
|
24
|
|
25 public MetaProtocolEngine_not(MetaLinda fdlmeta, int port) {
|
|
26 this.port = port;
|
|
27 }
|
|
28
|
|
29 public void metaOpen(int sendport){
|
|
30 try{
|
|
31 sendpsx = fdlmeta.open(host, sendport);
|
|
32 }catch (IOException e) {
|
|
33 e.printStackTrace();
|
|
34 }
|
|
35 }
|
|
36
|
|
37 //meta部分のデータ取得
|
|
38 public void metaTrans() {
|
|
39 try {
|
|
40 getpsx = fdlmeta.open(host, 10001);
|
|
41 } catch (IOException e) {
|
|
42 e.printStackTrace();
|
|
43 }
|
|
44 PSXReply in = getpsx.in(id);
|
|
45 while (running) {
|
|
46 System.out.println(in);
|
|
47 System.out.println(in.ready());
|
|
48 if(in.ready()) {
|
|
49 data = in.getData();
|
|
50 sendpsx.out(id, data);
|
|
51 running = false;
|
|
52 break;
|
|
53 }
|
|
54 }
|
|
55 }
|
|
56
|
|
57
|
|
58 public void mainLoop() {
|
|
59 System.out.println("MetaProtocolEngine Start");
|
|
60 fdlmeta = FederatedLinda.init();
|
|
61 if( port == 10002 ) {
|
|
62 metaOpen(10003);
|
|
63 metaTrans();
|
|
64 try {
|
|
65 fdlmeta.sync();
|
|
66 } catch (IOException e) {
|
|
67 e.printStackTrace();
|
|
68 }
|
|
69 System.out.println("MetaProtocolEngine Connect");
|
|
70 }
|
|
71
|
|
72 }
|
|
73
|
|
74 }
|