當前位置: 首頁>>代碼示例>>Java>>正文


Java Proxy類代碼示例

本文整理匯總了Java中battlecode.server.proxy.Proxy的典型用法代碼示例。如果您正苦於以下問題:Java Proxy類的具體用法?Java Proxy怎麽用?Java Proxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Proxy類屬於battlecode.server.proxy包,在下文中一共展示了Proxy類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Server

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
/**
 * Initializes a new server.
 *
 * @param args    the command line arguments that the server should use
 * @param proxies the proxies to use for this server
 */
public Server(Config options, Mode mode, Controller controller,
              Proxy... proxies) {
    this.matches = new LinkedList<Match>();
    this.finished = new LinkedList<Match>();

    this.mode = mode;
    this.controller = controller;
    this.proxies = new LinkedList<Proxy>();
    for (Proxy proxy : proxies)
        this.proxies.add(proxy);

    this.options = options;
    this.state = State.NOT_READY;
    this.nHandler = new ServerNotificationHandler();
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:22,代碼來源:Server.java

示例2: createPipeServer

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public static Server createPipeServer(Config options,
                                      String saveFile) throws IOException {

    Controller controller = ControllerFactory
            .createTCPController(System.in, options);

    List<Proxy> proxies = new LinkedList<Proxy>();

    if (saveFile != null)
        proxies.add(ProxyFactory.createProxyFromFile(saveFile));

    proxies.add(ProxyFactory.createProxy(System.out));

    // since we're sending the match file to System.out, don't send log
    // messages there
    System.setOut(System.err);

    Server server = new Server(options, Server.Mode.TCP, controller,
            proxies.toArray(new Proxy[proxies.size()]));
    controller.addObserver(server);
    return server;
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:23,代碼來源:ServerFactory.java

示例3: dumpFile

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public void dumpFile() {
    try {
        Proxy output = ProxyFactory.createProxyFromFile(filename + ".analyzed");
        output.open();
        for (GameData game : games) {
            game.renormalize();
            for (Object data : game.getOutput()) {
                output.writeObject(data);
            }
        }
        output.close();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(-2);
    }
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:17,代碼來源:AwesomenessAnalyzer.java

示例4: visitPauseNotification

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public Void visitPauseNotification(PauseNotification n) {
    state = State.PAUSED;
    for (Proxy p : proxies) {
        try {
            p.writeObject(n);
        } catch (IOException e) {
            warn("debug mode notification propagation failed");
        }
    }
    return null;
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:12,代碼來源:Server.java

示例5: setupMatches

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
/**
 * Sets up a new series of matches. Blocks until the matches have been set
 * up.
 *
 * @throws IOException if a match could not be setup
 */
private void setupMatches() throws IOException {

    debug("using controller " + this.controller.getClass().getSimpleName());
    controller.start();

    for (Proxy p : this.proxies) {
        debug("starting proxy " + p.getClass().getSimpleName());
        p.open();
    }
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:17,代碼來源:Server.java

示例6: run

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public void run() {
    if (round != null) {
        try {
            for (Proxy p : proxies) {
                p.writeRound(round);
                p.writeStats(stats);
            }
        } catch (IOException e) {
            ErrorReporter.report(e, false);
        }
        round = null;
        stats = null;
    }
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:15,代碼來源:Server.java

示例7: createHeadlessServer

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public static Server createHeadlessServer(Config options, String saveFile)
        throws IOException {

    Controller controller = ControllerFactory
            .createHeadlessController(options);

    Proxy[] proxies = new Proxy[]{ProxyFactory
            .createProxyFromFile(saveFile)};

    Server server = new Server(options, Server.Mode.HEADLESS, controller,
            proxies);
    controller.addObserver(server);

    return server;
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:16,代碼來源:ServerFactory.java

示例8: createLocalController

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public static Controller createLocalController(Config options, Proxy proxy) {
    return new LocalController(options, proxy);
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:4,代碼來源:ControllerFactory.java

示例9: LocalController

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public LocalController(Config options, Proxy proxy) {
    this.proxy = proxy;
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:4,代碼來源:LocalController.java

示例10: createLocalServer

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public static Server createLocalServer(Config options, Proxy proxy,
                                       String saveFile) throws IOException {

    Controller controller = ControllerFactory.createLocalController(options, proxy);

    List<Proxy> proxies = new LinkedList<Proxy>();
    if (saveFile != null)
        proxies.add(ProxyFactory.createProxyFromFile(saveFile));

    proxies.add(proxy);

    Server server = new Server(options, Server.Mode.LOCAL, controller,
            proxies.toArray(new Proxy[0]));

    controller.addObserver(server);

    return server;
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:19,代碼來源:ServerFactory.java

示例11: createRemoteServer

import battlecode.server.proxy.Proxy; //導入依賴的package包/類
public static Server createRemoteServer(Config options, int port,
                                        String saveFile) throws IOException {

    RPCServer rpcServer;
    Thread rpcThread;

    final MatchInputFinder finder = new MatchInputFinder();

    // Start a new RPC server for handling match input requests.
    rpcServer = new RPCServer() {
        public Object handler(Object arg) {
            if ("find-match-inputs".equals(arg))
                return finder.findMatchInputsLocally();
            return null;
        }
    };

    // Run it in a new thread.
    rpcThread = new Thread(rpcServer);
    rpcThread.setDaemon(true);
    rpcThread.start();

    // Start a server socket listening on the default port.
    ServerSocket serverSocket = new ServerSocket(port);
    Socket clientSocket = serverSocket.accept();
    // serverSocket.close(); (?)

    Controller controller = ControllerFactory
            .createTCPController(clientSocket.getInputStream(), options);

    List<Proxy> proxies = new LinkedList<Proxy>();

    if (saveFile != null)
        proxies.add(ProxyFactory.createProxyFromFile(saveFile));

    proxies.add(ProxyFactory.createProxy(clientSocket.getOutputStream()));

    Server server = new Server(options, Server.Mode.TCP, controller,
            proxies.toArray(new Proxy[proxies.size()]));
    controller.addObserver(server);
    return server;
}
 
開發者ID:jaaso,項目名稱:battlecode-2013-server,代碼行數:43,代碼來源:ServerFactory.java


注:本文中的battlecode.server.proxy.Proxy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。