Mercurial > hg > Applications > AliceVNC
view src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveAliceVNCMessage.java @ 34:aace9df1462e
refactor
author | sugi |
---|---|
date | Thu, 13 Nov 2014 16:09:09 +0900 |
parents | src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveChangeRequest.java@7d65ad341cc9 |
children | 9354e8a1d03b |
line wrap: on
line source
package jp.ac.u_ryukyu.alicevnc; import java.util.List; import jp.ac.u_ryukyu.alicevnc.AliceVNCMessage.MessageType; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class ReceiveAliceVNCMessage extends CodeSegment { private Receiver info = ids.create(CommandType.TAKE); private Receiver info1 = ids.create(CommandType.PEEK); // connection list public ReceiveAliceVNCMessage() { info.setKey("AliceVNCMessage"); info1.setKey("_CLIST"); } @Override public void run() { AliceVNCMessage order = info.asClass(AliceVNCMessage.class); @SuppressWarnings("unchecked") List<String> clist = info1.asClass(List.class); if (order.messageID == MessageType.ChangeRequest.getId()|| order.messageID == MessageType.CurrentVNCInfo.getId()) { if (clist.contains("parent")){ order.route.add(info.from); ods.put("parent", "AliceVNCMessage", order); new ReceiveAliceVNCMessage(); } else { // this node is root. order.route.add(info.from); if (order.messageID == MessageType.CurrentVNCInfo.getId()) { ods.put("currentServer", order); new ReceiveAliceVNCMessage(); } else { new CheckCurrentInfo(order); // check change Server flag. } } } else if (order.messageID == MessageType.StartNegotiate.getId()|| order.messageID == MessageType.StopProxy.getId()|| order.messageID == MessageType.DeniedRequest.getId()) { if (order.route.size() == 0) { // this node send ChangeVNCRequest if (order.messageID == MessageType.StartNegotiate.getId()){ // negotiate VNCServer by Viewer ods.put("vncRight", true); new NegotiateVNCServer(); new ReceiveAliceVNCMessage(); } else if(order.messageID == MessageType.StopProxy.getId()) { new StopProxy(); } else if (order.messageID == MessageType.DeniedRequest.getId()) { // pop up window or message } } else { String address = order.getNextAddress(); ods.put(address, "AliceVNCMessage", order); new ReceiveAliceVNCMessage(); } } } }