view src/main/java/jp/ac/u_ryukyu/alicevnc/NegotiateVNCServer.java @ 47:9354e8a1d03b

working AliceVNC
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Mon, 19 Oct 2015 23:48:18 +0900
parents aace9df1462e
children 57ca704f86a3
line wrap: on
line source

package jp.ac.u_ryukyu.alicevnc;

import java.util.ArrayList;

import jp.ac.u_ryukyu.alicevnc.AliceVNCMessage.MessageType;

import com.glavsoft.viewer.Viewer;

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

public class NegotiateVNCServer extends CodeSegment {
    private Receiver info = ids.create(CommandType.PEEK);
    private Receiver info1 = ids.create(CommandType.PEEK);

    public NegotiateVNCServer(CodeSegment cs){
        this.aliceDaemon = cs.aliceDaemon;
        info.setKey("host", this);
        info1.setKey("AliceVNCConfig", this);
    }

    @Override
    public void run() {
        AliceVNCConfig conf = info1.asClass(AliceVNCConfig.class);
        String hostname = info.asString();

        // root node connect to vnc Server first time.
        String[] args = {"localhost"};
        // negotiate VNCServer by Viewer
        Viewer.main(args);

        // currentServer Info
        AliceVNCMessage currentServerInfo = new AliceVNCMessage(MessageType.CurrentVNCInfo);
        currentServerInfo.name = hostname;
        currentServerInfo.allowChange = conf.getAllowChange();
        ArrayList<String> list = new ArrayList<String>();
        currentServerInfo.route = list;
        ods.put("AliceVNCMessage", currentServerInfo);

    }

}