本文整理汇总了Java中com.esotericsoftware.kryonet.FrameworkMessage类的典型用法代码示例。如果您正苦于以下问题:Java FrameworkMessage类的具体用法?Java FrameworkMessage怎么用?Java FrameworkMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FrameworkMessage类属于com.esotericsoftware.kryonet包,在下文中一共展示了FrameworkMessage类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.esotericsoftware.kryonet.FrameworkMessage; //导入依赖的package包/类
@Override
public void write(ByteBuffer byteBuffer, Object o) {
if(o instanceof FrameworkMessage){
byteBuffer.put((byte)-2); //code for framework message
FrameworkSerializer.write(byteBuffer, (FrameworkMessage)o);
}else {
if (!(o instanceof Packet))
throw new RuntimeException("All sent objects must implement be Packets! Class: " + o.getClass());
byte id = Registrator.getID(o.getClass());
if (id == -1)
throw new RuntimeException("Unregistered class: " + ClassReflection.getSimpleName(o.getClass()));
byteBuffer.put(id);
((Packet) o).write(byteBuffer);
}
}
示例2: received
import com.esotericsoftware.kryonet.FrameworkMessage; //导入依赖的package包/类
@Override
public void received(Connection conn, Object inPacket)
{
if (inPacket instanceof FrameworkMessage)
return;
if (inPacket instanceof P1_KeyVerifier)
{
P1_KeyVerifier packet = (P1_KeyVerifier) inPacket;
connectionData.setPublicKey(packet.getPublicKey());
if (!packet.checkEncryption(connectionData))
{
conn.close();
return;
}
connectionData.handshakeCompleted();
Log.trace("Handshake completo, id: " + conn.getID(), LogTraceType.HANDSHAKE_COMPLETED);
P2_KeyVerifier outPacket = new P2_KeyVerifier();
outPacket.writePacket(connectionData, packet, null);
conn.sendTCP(outPacket);
}
else if (inPacket instanceof IPacket)
connectionData.elaboratePacket((IPacket) inPacket);
else
Log.localizedWarn("[UNKNOW_PACKET]", inPacket.getClass().getName());
}
示例3: PacketHandlerFactory
import com.esotericsoftware.kryonet.FrameworkMessage; //导入依赖的package包/类
public PacketHandlerFactory(final PlayState playState, final StateManager states)
{
packetHandlers.put(AuthenticationReplyPacket.class, new AuthenticationReplyPacketHandler(states));
packetHandlers.put(CharacterCreationReplyPacket.class, new CharacterCreationReplyPacketHandler(states));
packetHandlers.put(CharacterItemDataPacket.class, new CharacterItemDataPacketHandler(playState));
packetHandlers.put(ObjectCreationPacket.class, new ObjectCreationPacketHandler(playState));
packetHandlers.put(ObjectRemovePacket.class, new ObjectRemovePacketHandler(playState));
packetHandlers.put(ObjectRepositionPacket.class, new ObjectRepositionPacketHandler(playState));
packetHandlers.put(RegisterationReplyPacket.class, new RegisterationReplyPacketHandler(states));
packetHandlers.put(UserCharacterDataPacket[].class, new UserCharacterDataArrayPacketHandler(states));
packetHandlers.put(ChatMessageReplyPacket.class, new ChatMessageReplyPacketHandler(playState));
packetHandlers.put(MonsterTargetingReplyPacket.class,
new CharacterMonsterTargetingReplyPacketHandler(playState));
packetHandlers.put(NormalDamagePacket.class, new NormalDamagePacketHandler(playState));
packetHandlers.put(FireDamagePacket.class, new FireDamagePacketHandler(playState));
packetHandlers.put(MonsterCreationPacket.class, new MonsterCreationPacketHandler(playState));
packetHandlers.put(ExperienceGainPacket.class, new ExperienceGainPacketHandler(playState));
packetHandlers.put(PlayerCreationPacket.class, new PlayerCreationPacketHandler(playState));
packetHandlers.put(HpChangeByItemUsagePacket.class, new HpChangeByItemUsagePacketHandler(playState));
packetHandlers.put(MpChangeByItemUsagePacket.class, new MpChangeByItemUsagePacketHandler(playState));
packetHandlers.put(ManaDrainPacket.class, new ManaDrainPacketHandler(playState));
packetHandlers.put(ItemUsagePacket.class, new ItemUsagePacketHandler(playState));
packetHandlers.put(ContainerContentPacket.class, new ContainerContentPacketHandler(playState));
packetHandlers.put(ContainerItemRemovalPacket.class, new ContainerItemRemovalPacketHandler(playState));
packetHandlers.put(UnacceptableOperationPacket.class, new UnacceptableOperationPacketHandler(playState));
packetHandlers.put(GoldReceivePacket.class, new GoldReceivePacketHandler(playState));
packetHandlers.put(ContainerGoldRemovalPacket.class, new ContainerGoldRemovalPacketHandler(playState));
packetHandlers.put(HpUpdatePacket.class, new HpUpdatePacketHandler(playState));
packetHandlers.put(MpUpdatePacket.class, new MpUpdatePacketHandler(playState));
packetHandlers.put(ShopItemsPacket.class, new ShopItemsPacketHandler(playState));
packetHandlers.put(GoldAmountChangePacket.class, new GoldAmountChangePacketHandler(playState));
packetHandlers.put(ScriptExecutionErrorPacket.class, new ScriptExecutionErrorPacketHandler(playState));
packetHandlers.put(InventoryItemRepositionPacket.class, new InventoryItemRepositionPacketHandler(playState));
packetHandlers.put(InventoryItemSwapPacket.class, new InventoryItemSwapPacketHandler(playState));
packetHandlers.put(InventoryItemStackPacket.class, new InventoryItemStackPacketHandler(playState));
packetHandlers.put(ItemPutInQuickAccessBarPacket.class, new ItemPutInQuickAccessBarPacketHandler(playState));
packetHandlers.put(SpellPutInQuickAccessBarPacket.class, new SpellPutInQuickAccessBarPacketHandler(playState));
packetHandlers.put(ScriptResultInfoPacket.class, new ScriptResultInfoPacketHandler(playState));
packetHandlers.put(QuestBoardInfoPacket.class, new QuestBoardInfoPacketHandler(playState));
packetHandlers.put(QuestFinishedRewardPacket.class, new QuestFinishedRewardPacketHandler(playState));
packetHandlers.put(ItemRewardRemovePacket.class, new ItemRewardRemovePacketHandler(playState));
packetHandlers.put(QuestRewardGoldRemovalPacket.class, new QuestRewardGoldRemovalPacketHandler(playState));
packetHandlers.put(QuestStateInfoPacket[].class, new QuestStateInfoPacketArrayHandler(playState));
packetHandlers.put(QuestAcceptedPacket.class, new QuestAcceptedPacketHandler(playState));
packetHandlers.put(NpcStartDialogPacket.class, new NpcStartDialogPacketHandler(playState));
packetHandlers.put(NpcContinueDialogPacket.class, new NpcContinueDialogPacketHandler(playState));
packetHandlers.put(KnownSpellInfoPacket.class, new KnownSpellInfoPacketHandler(playState));
// Ignore framework keepAliveMessage
packetHandlers.put(FrameworkMessage.KeepAlive.class, new NullPacketHandler());
}
示例4: PacketHandlerFactory
import com.esotericsoftware.kryonet.FrameworkMessage; //导入依赖的package包/类
public PacketHandlerFactory(Map<Integer, UserInfo> loggedUsersKeyUserId,
Map<Integer, User> authenticatedClientsKeyClientId, Server server, PlayState playState)
{
GameDataRetriever gameDataRetriever = new GameDataRetriever(loggedUsersKeyUserId,
authenticatedClientsKeyClientId);
packetHandlers.put(AuthenticationPacket.class, new AuthenticationPacketHandler(loggedUsersKeyUserId,
authenticatedClientsKeyClientId, server, playState));
packetHandlers.put(CharacterCreationPacket.class,
new CharacterCreationPacketHandler(authenticatedClientsKeyClientId, server));
packetHandlers.put(CharacterChangePacket.class, new CharacterChangePacketHandler(loggedUsersKeyUserId,
authenticatedClientsKeyClientId, playState, server));
packetHandlers.put(DisconnectPacket.class, new DisconnectPacketHandler());
packetHandlers.put(GetUserCharactersPacket.class, new GetUserCharacterPacketHandler(server));
packetHandlers.put(LogoutPacket.class,
new LogoutPacketHandler(loggedUsersKeyUserId, authenticatedClientsKeyClientId, server, playState));
packetHandlers.put(RegisterationPacket.class, new RegisterationPacketHandler(server));
packetHandlers.put(UserCharacterDataPacket.class,
new UserCharacterDataPacketHandler(loggedUsersKeyUserId, server, playState));
packetHandlers.put(MoveLeftPacket.class, new MoveLeftPacketHandler(playState));
packetHandlers.put(MoveRightPacket.class, new MoveRightPacketHandler(playState));
packetHandlers.put(MoveUpPacket.class, new MoveUpPacketHandler(playState));
packetHandlers.put(MoveDownPacket.class, new MoveDownPacketHandler(playState));
packetHandlers.put(ChatMessagePacket.class, new ChatMessagePacketHandler(server, gameDataRetriever));
packetHandlers.put(BoardClickPacket.class, new CharacterBoardClickPacketHandler(playState, gameDataRetriever));
packetHandlers.put(ItemUsagePacket.class, new ItemUsagePacketHandler(gameDataRetriever, playState, server));
packetHandlers.put(FireballSpellUsagePacket.class,
new FireballSpellUsagePacketHandler(gameDataRetriever, playState));
packetHandlers.put(HealSpellUsagePacket.class,
new HealSpellUsagePacketHandler(gameDataRetriever, playState));
packetHandlers.put(OpenContainterPacket.class, new OpenContainerPacketHandler(server, playState));
packetHandlers.put(TakeItemFromContainerPacket.class,
new TakeItemFromContainerPacketHandler(gameDataRetriever, server, playState));
packetHandlers.put(TakingGoldFromContainerPacket.class,
new TakingGoldFromContainerPacketHandler(gameDataRetriever, server, playState));
packetHandlers.put(BuyFromShopPacket.class, new BuyFromShopPacketHandler(playState, gameDataRetriever));
packetHandlers.put(ScriptCodePacket.class,
new ScriptCodePacketHandler(playState, authenticatedClientsKeyClientId));
packetHandlers.put(InventoryItemRepositionRequestPacket.class,
new InventoryItemRepositionRequestPacketHandler(gameDataRetriever, playState));
packetHandlers.put(ItemPutInQuickAccessBarPacket.class,
new ItemPutInQuickAccessBarPacketHandler(playState, gameDataRetriever));
packetHandlers.put(ItemRemovedFromQuickAccessBarPacket.class,
new ItemRemovedFromQuickAccessBarPacketHandler(playState, gameDataRetriever));
packetHandlers.put(SpellPutInQuickAccessBarPacket.class,
new SpellPutInQuickAccessBarPacketHandler(playState, gameDataRetriever));
packetHandlers.put(SpellRemovedFromQuickAccessBarPacket.class,
new SpellRemovedFromQuickAccessBarPacketHandler(playState, gameDataRetriever));
packetHandlers.put(RetrieveItemRewardPacket.class,
new RetrieveItemRewardPacketHandler(gameDataRetriever, playState));
packetHandlers.put(RetrieveGoldRewardPacket.class,
new RetrieveGoldRewardPacketHandler(gameDataRetriever, playState));
packetHandlers.put(AcceptQuestPacket.class, new AcceptQuestPacketHandler(gameDataRetriever));
packetHandlers.put(NpcConversationAnwserChoosenPacket.class,
new NpcConversationAnwserChoosenPacketHandler(playState, gameDataRetriever));
// Ignore framework packets
packetHandlers.put(FrameworkMessage.KeepAlive.class, new NullPacketHandler());
}
示例5: handleReceived
import com.esotericsoftware.kryonet.FrameworkMessage; //导入依赖的package包/类
private void handleReceived(Connection conn, Object obj) {
//Log.debug("received from server: " + obj);
if (obj == null) {
Log.error("received null object from kryonet");
}
if (obj instanceof ServerMessage.AssignPlayerEntityId) {
handleAssignPlayerEntityId((ServerMessage.AssignPlayerEntityId) obj);
}
else if (obj instanceof ServerMessage.DestroyEntity) {
ServerMessage.DestroyEntity destroy = (ServerMessage.DestroyEntity) obj;
Main.inst.clientEventManager.addEventToQueue(new ClientEvent.DestroyEntity(destroy.id));
}
else if (obj instanceof ServerMessage.ServerInfo) {
handleServerInfo((ServerMessage.ServerInfo) obj);
}
else if (obj instanceof ServerMessage.LevelGeometry) {
handleLevelGeometry((ServerMessage.LevelGeometry) obj);
}
else if (obj instanceof ChatMessage) {
ChatMessage chat = (ChatMessage) obj;
// creation time based on when client receives it, override the value
chat.createTime = TimeUtils.millis();
Main.inst.clientEventManager.addEventToQueue(new ClientEvent.ReceivedChatMessage(chat));
}
else if (obj instanceof ServerUpdate) {
ServerUpdate serverUpdate = (ServerUpdate) obj;
if (serverUpdate.tickNum <= highestTickNumUpdateReceived) {
Log.debug("discarding outdated serverupdate, ticknum: " + serverUpdate.tickNum + ", current tick: " + highestTickNumUpdateReceived);
return;
}
/*long now = TimeUtils.millis();
long elapsed = now - lastServerUpdateTime;
lastServerUpdateTime = now;
Log.debug("server update elapsed time (tick: " + serverUpdate.tickNum + "): " + elapsed);*/
handleUpdateFromServer(serverUpdate);
}
else if (obj instanceof EntityInfoRequest.Response) {
handleEntityInfoRequestResponse((EntityInfoRequest.Response) obj);
}
else if (obj instanceof FrameworkMessage.Ping) {
if (((FrameworkMessage.Ping) obj).isReply) {
ping = client.getReturnTripTime();
//System.out.println("new ping: " + ping);
}
}
else if (obj instanceof BulletPackage) {
handleBulletPackage((BulletPackage) obj);
} else {
//Log.debug("unhandled object from server: " + obj);
if (!obj.getClass().getName().contains("com.esotericsoftware.kryonet")) {
throw new GdxRuntimeException("unhandled object from server: " + obj);
}
}
}
示例6: received
import com.esotericsoftware.kryonet.FrameworkMessage; //导入依赖的package包/类
public void received(Connection connection, Object object) {
if (object instanceof CameraMessage) {
CameraMessage message = (CameraMessage) object;
CameraConnection cameraConnection = (CameraConnection) connection;
switch (message.messageId) {
case UPDATE_CAR:
UpdateCarMessage updateCarMsg = (UpdateCarMessage) message;
if (!cameraConnection.isValidUpdateCarMessage(updateCarMsg.seqNr))
break;
_moderator.updateCar(updateCarMsg.carId, updateCarMsg.posX, updateCarMsg.posY,
updateCarMsg.direction);
break;
case CAR_DETECTED:
CarDetectedMessage carDetectedMsg = (CarDetectedMessage) message;
// get the car image
BufferedImage carImage = null;
if (carDetectedMsg.image != null && carDetectedMsg.image.length > 0) {
try {
InputStream in = new ByteInputStream(carDetectedMsg.image,
carDetectedMsg.image.length);
carImage = ImageIO.read(in);
in.close();
} catch (IOException e) {
_logger.error("Exception caught while reading car image!", e);
}
} else {
_logger.error("No image received for car with id: {}", carDetectedMsg.carId);
}
if (carImage != null) {
Car<Player> car = new Car<Player>(carDetectedMsg.carId, new Position(
carDetectedMsg.posX, carDetectedMsg.posY), new Direction(
carDetectedMsg.direction), carImage);
_moderator.carDetected(car);
}
break;
case CONFIGURE_MAP:
ConfigureMapMessage configureMapMsg = (ConfigureMapMessage) message;
_moderator.configureMap(configureMapMsg.sizeX, configureMapMsg.sizeY);
break;
case DETECTION_FINISHED:
_moderator.detectionFinished();
break;
default:
_logger.warn("Camera message with id: {} not known!", message.messageId);
break;
}
} else if (object instanceof FrameworkMessage.KeepAlive) {
// _logger.debug("Received Camera keepAlive ...");
}
}