我正在尝试使用kryonet创建游戏服务器和客户端。 当我连接时,服务器显示连接但客户端没有收到我发送的信息。
这是连接功能的服务器:
@Override
public void connected(Connection e) {
super.connected(e);
System.out.println(e.getRemoteAddressTCP().getHostName() + " has connected");
Character character = CharacterLoader.getCharacter("wizard");
GameInformation gInfo = new GameInformation();
gInfo.setCharacter(character);
gInfo.setWorld(currentWorld);
gInfo.setGame(new CoreGame(gInfo));
players.add(gInfo);
currentWorld.addToRoot(gInfo.getCharacter());
Packet00GameInfo info = new Packet00GameInfo();
info.me = gInfo;
e.sendTCP(info);
}
以下是接收功能的客户端:
@Override
public void received(Connection e, Object o) {
super.received(e, o);
if(o instanceof Packet00GameInfo){
info = ((Packet00GameInfo) o).me;
System.out.println("received!");
}
}