本文整理汇总了Java中com.esotericsoftware.kryonet.Connection.getID方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.getID方法的具体用法?Java Connection.getID怎么用?Java Connection.getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esotericsoftware.kryonet.Connection
的用法示例。
在下文中一共展示了Connection.getID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: userChoosenCharcter
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
private void userChoosenCharcter(int userCharacterId, Connection connection)
{
Character character = characterRepo.findOneAndFetchEverythingRelated(userCharacterId);
UserInfo info = loggedUsersKeyUserId.get(character.getUser().getId());
info.userCharacter = character;
int clientId = connection.getID();
sendCurrentGameObjectsInfo(connection);
PlayerCharacter newPlayer = new PlayerCharacter(character, playState, clientId);
Collection<Item> playerItems = getPlayerItems(newPlayer);
playerItems.forEach((item) -> newPlayer.addItemDenyStacking(item));
playState.add(newPlayer);
server.sendToAllExceptTCP(clientId, PacketsMaker.makeCreationPacket(newPlayer));
sendItemsDataToClient(playerItems, connection);
sendItemQuickAccessBarConfigToClient(character.getItemQuickAccessBarConfig().values(), connection);
sendSpellQuickAccessBarConfigToClient(character.getSpellQuickAccessBarConfig().values(), connection);
sendQuestInfoToClient(character.getQuests(), connection);
sendAvailableSpellsToClient(character.getSpells(), connection);
}
示例2: connected
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
@Override
public void connected(Connection connection) {
if (getWorld().isGameOver() ||
(getWorld().getPlayers().size() >= 2 &&
Parameters.restrictJoin)) {
sendEventToPlayer(Event.ON_CONNECTION_REFUSED, -1, connection.
getID());
return;
}
final int playerID = connection.getID();
((ServerWorld) world).addPlayer(playerID);
sendStateToPlayer(playerID);
sendTileUpdateToPlayer(playerID);
System.out.println("Client connected! ID# " + playerID);
}
示例3: getUsername
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
private String getUsername(Connection connection) {
for (Game game : gamesMap.values()) {
for (Map.Entry<Account, Integer> accountIntegerEntry : game.peers.entrySet()) {
if (accountIntegerEntry.getValue() == connection.getID()) {
return accountIntegerEntry.getKey().getUsername();
}
}
}
return null;
}
示例4: sendCommand
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
public void sendCommand(int id, NetCommand cmd) {
for(Connection c : server.getConnections()) {
if(c.getID() == id) {
Update response = new Update();
response.cmd = cmd;
c.sendTCP(response);
break;
}
}
}
示例5: sendStateToAll
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
public void sendStateToAll() {
PacketServerStatus pOptions = (PacketServerStatus) Packet.createPacket(
PacketServerStatus.class, CONNECTED, -1);
pOptions.currentLevelID = getWorld().getCurrentLevel().getLevelID();
pOptions.currentEnemies = getWorld().totalEnemies();
pOptions.worldInitiated = getWorld().isWorldInitiated();
for (Connection c : getConnections()) {
int id = c.getID();
pOptions.playerLives = ((PlayerTank) getWorld().getPlayer(id)).
getPlayerLives();
sendToTCP(id, pOptions);
}
}
示例6: disconnected
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
@Override
public void disconnected(Connection connection) {
int playerID = connection.getID();
PlayerTank pTank = (PlayerTank) getWorld().getPlayer(playerID);
if (pTank != null) {
pTank.setState(State.DEAD);
getWorld().removePlayer(playerID);
System.out.println("Client disconnected! ID#" + connection.
getID());
}
}
示例7: doMessageDisconnect
import com.esotericsoftware.kryonet.Connection; //导入方法依赖的package包/类
public void doMessageDisconnect(Connection connection) {
WindowController.addConsoleMsg("Disonnected: Client ID " + connection.getID());
for (java.util.Map.Entry<String, Player> entry : this.targets.getPlayers().entrySet()) {
if (entry.getValue().getConnection().getID() == connection.getID()) {
this.doMessagePlayerDelete(new MessagePlayerDelete(entry.getKey(), entry.getValue().getPseudo()));
}
}
}