diff src/main/java/alice/test/chat/SendMessage.java @ 601:30f2c04571c2 dispose

add chat, add Star topology to topology manager&node
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Wed, 27 Apr 2016 16:28:10 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/alice/test/chat/SendMessage.java	Wed Apr 27 16:28:10 2016 +0900
@@ -0,0 +1,39 @@
+package alice.test.chat;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+import java.util.ArrayList;
+
+/**
+ * Created by e125769 on 3/29/16.
+ */
+public class SendMessage extends CodeSegment{
+
+    private Receiver info = ids.create(CommandType.TAKE);
+    private Receiver info1 = ids.create(CommandType.PEEK);
+    private ChatWindow chatWindow;
+
+    public SendMessage(ChatWindow chatWindow) {
+        this.chatWindow = chatWindow;
+        info.setKey("local", "sendMessage");
+        info1.setKey("local", "_CLIST");
+    }
+
+    @Override
+    public void run() {
+        ArrayList<String> clist = info1.asClass(ArrayList.class);
+
+        if (clist.contains("parent")){//子ノード
+            ods.put("parent", "sendMessage", info.asString());
+        } else {//親ノード
+            chatWindow.show(info.asString());
+            for (String node : clist){
+                ods.put(node, "receiveMessage", info.asString());
+            }
+        }
+
+        new SendMessage(chatWindow);
+    }
+}