view src/main/java/jp/ac/u_ryukyu/alicevnc/CheckMyName.java @ 86:4a8755a30aa8 default tip

add topology manager number to 'host' key
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Wed, 10 Feb 2016 22:54:46 +0900
parents 3a27a0727705
children
line wrap: on
line source

package jp.ac.u_ryukyu.alicevnc;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.DataSegment;
import alice.datasegment.Receiver;

public class CheckMyName extends CodeSegment {

    private int topMNumber;
    private Receiver info = ids.create(CommandType.PEEK);

    public CheckMyName(int topMNumber){
        this.topMNumber = topMNumber;
        for (int i = 1; i <= topMNumber; i++) {
            info.setKey("host"+i);
        }
    }

    @Override
    public void run() {
        //System.out.println("CheckMyName host index:" + DataSegment.getLocal().getDSindex("host"));
        if ("node0".equals(info.asString())) {
            new CreateWindow("local");
            new NegotiateVNCServer(topMNumber);
        } else {
            new CreateWindow("parent");
        }

        new ReceiveAliceVNCMessage(topMNumber);
        new SendChangeRequest(topMNumber);
    }

}