当前位置: 首页>>代码示例>>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;未经允许,请勿转载。