本文整理汇总了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();
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例8: createLocalController
import battlecode.server.proxy.Proxy; //导入依赖的package包/类
public static Controller createLocalController(Config options, Proxy proxy) {
return new LocalController(options, proxy);
}
示例9: LocalController
import battlecode.server.proxy.Proxy; //导入依赖的package包/类
public LocalController(Config options, Proxy proxy) {
this.proxy = proxy;
}
示例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;
}
示例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;
}