Package networking.response

Source Code of networking.response.ResponseSeeOnlinePlayers

package networking.response;

import java.util.List;
import metadata.Constants;
import model.Player;
import utility.GamePacket;

/**
*
* @author Xuyuan
*/
public class ResponseSeeOnlinePlayers extends GameResponse {

    private List<Player> onlinePlayers;

    public ResponseSeeOnlinePlayers() {
        responseCode = Constants.SMSG_SEEONLINEPLAYERS;
    }

    public void setOnlinePlayers(List<Player> onlinePlayers) {
        this.onlinePlayers = onlinePlayers;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addShort16((short) onlinePlayers.size());

        for (Player player : onlinePlayers) {
            packet.addInt32(player.getID());
            packet.addString(player.getUsername());
        }

        return packet.getBytes();
    }
}
TOP

Related Classes of networking.response.ResponseSeeOnlinePlayers

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.