本文整理汇总了Java中net.sf.freecol.common.networking.DisconnectMessage类的典型用法代码示例。如果您正苦于以下问题:Java DisconnectMessage类的具体用法?Java DisconnectMessage怎么用?Java DisconnectMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisconnectMessage类属于net.sf.freecol.common.networking包,在下文中一共展示了DisconnectMessage类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import net.sf.freecol.common.networking.DisconnectMessage; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Message handle(Connection connection, Message message)
throws FreeColException {
final FreeColServer freeColServer = getFreeColServer();
ChangeSet cs = null;
switch (message.getType()) {
case DisconnectMessage.TAG:
break;
case LoginMessage.TAG:
cs = ((LoginMessage)message).loginHandler(freeColServer, connection);
break;
default:
cs = ChangeSet.clientError((ServerPlayer)null,
StringTemplate.template("server.couldNotLogin"));
break;
}
ServerPlayer serverPlayer = freeColServer.getPlayer(connection);
return (cs == null) ? null : cs.build(serverPlayer);
}
示例2: handle
import net.sf.freecol.common.networking.DisconnectMessage; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Message handle(Connection connection, Message message)
throws FreeColException {
if (message == null) return null;
final String tag = message.getType();
switch (tag) {
case DisconnectMessage.TAG:
break;
case ServerListMessage.TAG:
ServerListMessage slm = (ServerListMessage)message;
this.consumer.accept(slm.getServers());
break;
default:
logger.warning("MetaInputHandler does not handle: " + tag);
break;
}
return null;
}
示例3: handle
import net.sf.freecol.common.networking.DisconnectMessage; //导入依赖的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;
}