当前位置: 首页>>代码示例>>Java>>正文


Java ProxyFactory类代码示例

本文整理汇总了Java中battlecode.server.proxy.ProxyFactory的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory类的具体用法?Java ProxyFactory怎么用?Java ProxyFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProxyFactory类属于battlecode.server.proxy包,在下文中一共展示了ProxyFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPipeServer

import battlecode.server.proxy.ProxyFactory; //导入依赖的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

示例2: dumpFile

import battlecode.server.proxy.ProxyFactory; //导入依赖的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

示例3: Server

import battlecode.server.proxy.ProxyFactory; //导入依赖的package包/类
/**
 * Initializes a new server.
 *
 * @param options the configuration to use
 * @param interactive whether to wait for notifications to control the
 *                    match run state
 * @param proxyFactories the factories to use to create proxies for each
 *                       game (decoupled enough for you?)
 */
public Server(Config options, boolean interactive, ProxyFactory... proxyFactories) {
    this.gameQueue = new LinkedBlockingQueue<>();
    this.proxyFactories = proxyFactories;

    this.interactive = interactive;

    this.options = options;
    this.state = State.NOT_READY;
}
 
开发者ID:battlecode,项目名称:battlecode-server-2016,代码行数:19,代码来源:Server.java

示例4: createHeadlessServer

import battlecode.server.proxy.ProxyFactory; //导入依赖的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

示例5: createLocalServer

import battlecode.server.proxy.ProxyFactory; //导入依赖的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

示例6: createRemoteServer

import battlecode.server.proxy.ProxyFactory; //导入依赖的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.ProxyFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。