本文整理汇总了Java中net.sf.freecol.common.networking.UpdateServerMessage类的典型用法代码示例。如果您正苦于以下问题:Java UpdateServerMessage类的具体用法?Java UpdateServerMessage怎么用?Java UpdateServerMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UpdateServerMessage类属于net.sf.freecol.common.networking包,在下文中一共展示了UpdateServerMessage类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: metaMessage
import net.sf.freecol.common.networking.UpdateServerMessage; //导入依赖的package包/类
/**
* Send a message to the meta-server.
*
* @param type The {@code MetaMessageType} to send.
* @param si The associated {@code ServerInfo}.
* @return True if the operation succeeds.
*/
private static boolean metaMessage(MetaMessageType type, ServerInfo si) {
try (Connection mc = getMetaServerConnection(null)) {
if (mc == null) return false;
si.setConnection(mc.getName(), mc.getHostAddress(), mc.getPort());
switch (type) {
case REGISTER:
mc.sendMessage(new RegisterServerMessage(si));
return startTimer(si);
case REMOVE:
mc.sendMessage(new RemoveServerMessage(si));
return stopTimer(si);
case UPDATE:
mc.sendMessage(new UpdateServerMessage(si));
return updateTimer(si);
default:
logger.log(Level.WARNING, "Wrong metaMessage type: " + type);
return false;
}
} catch (Exception ex) {
logger.log(Level.WARNING, "Meta-server " + type.toString()
+ " failed: " + FreeCol.getMetaServerAddress()
+ ":" + FreeCol.getMetaServerPort(), ex);
}
return false;
}
示例2: handle
import net.sf.freecol.common.networking.UpdateServerMessage; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Message handle(Connection connection, Message message)
throws FreeColException {
if (message == null) return null;
Message reply = null;
final String tag = message.getType();
switch (tag) {
case DisconnectMessage.TAG:
disconnect(connection);
break;
case RegisterServerMessage.TAG:
RegisterServerMessage rsm = (RegisterServerMessage)message;
rsm.setAddress(connection.getHostAddress()); // Trust the connection
register(rsm);
break;
case RemoveServerMessage.TAG:
remove((RemoveServerMessage)message);
break;
case ServerListMessage.TAG:
reply = serverList();
break;
case UpdateServerMessage.TAG:
UpdateServerMessage usm = (UpdateServerMessage)message;
usm.setAddress(connection.getHostAddress()); // Trust the connection
update(usm);
break;
default:
logger.warning("Unknown request: " + tag);
break;
}
return reply;
}
示例3: update
import net.sf.freecol.common.networking.UpdateServerMessage; //导入依赖的package包/类
/**
* Handle an "update"-request.
*
* @param message The {@code UpdateServerMessage} to process.
*/
private void update(UpdateServerMessage message) {
final ServerInfo si = message.getServerInfo();
metaRegister.updateServer(si);
}