當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。