本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}