Package rbafw.main

Source Code of rbafw.main.Agent

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package rbafw.main;

import java.util.logging.Handler;
import java.util.logging.Level;
import rbafw.fsmhandler.PlayModeHandler;
import rbafw.fsmhandler.RBAFWHandler;
import rbafw.fsmhandler.UpdateWordHandler;
import robobeans.ServerManager;

/**
*
* @author ahmed-s-ghonim
*/
public class Agent {

    private RBAFWHandler handler;
    private ServerManager si;
    private boolean startLock = false;

    public Agent(UpdateWordHandler updateWorldHandler, PlayModeHandler playModeHandler, String teamName, boolean isGoalie) throws Exception {
        this(updateWorldHandler, playModeHandler, teamName, isGoalie, null);
    }

    public Agent(UpdateWordHandler updateWorldHandler, PlayModeHandler playModeHandler, String teamName, boolean isGoalie, Integer serverVersionNumber) throws Exception {
        this.handler = new RBAFWHandler(updateWorldHandler, playModeHandler);
        si = new ServerManager(handler);
        si.setTeamName(teamName);
        si.setIsgoalie(isGoalie);
        if (serverVersionNumber != null) {
            si.setServerVersionNumber(serverVersionNumber);
        }
    }

    public void setServerLogLevel(Level level) {
        si.getLogger().setLevel(level);
    }

    public void setFrameworkLogLevel(Level level) {
        this.handler.getLogger().setLevel(level);
    }

    public void addServerLogHandler(Handler handler) {
        si.getLogger().addHandler(handler);
    }

    public void addFrameworkLogHandler(Handler handler) {
        this.handler.getLogger().addHandler(handler);
    }

    public void start() {
        if (!startLock) {
            startLock = true;
            si.start();
        }
    }
}
TOP

Related Classes of rbafw.main.Agent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.