当前位置: 首页>>代码示例>>Java>>正文


Java Connection.getID方法代码示例

本文整理汇总了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);
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:20,代码来源:UserCharacterDataPacketHandler.java

示例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);
}
 
开发者ID:jh62,项目名称:Battle-City-Multiplayer,代码行数:18,代码来源:Server.java

示例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;
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:11,代码来源:CatanServer.java

示例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;
		}
	}
}
 
开发者ID:edwardszczepanski,项目名称:QuackHack,代码行数:11,代码来源:NetServer.java

示例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);
    }
}
 
开发者ID:jh62,项目名称:Battle-City-Multiplayer,代码行数:16,代码来源:Server.java

示例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());
    }
}
 
开发者ID:jh62,项目名称:Battle-City-Multiplayer,代码行数:14,代码来源:Server.java

示例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()));
        }
    }
}
 
开发者ID:LeNiglo,项目名称:TinyTank,代码行数:9,代码来源:GameController.java


注:本文中的com.esotericsoftware.kryonet.Connection.getID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。