com.esotericsoftware.kryonet.FrameworkMessage Java Examples
The following examples show how to use
com.esotericsoftware.kryonet.FrameworkMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NetClient.java From gdx-proto with Apache License 2.0 | 4 votes |
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); } } }