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