package cactusServer.resources; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.ntlab.radishforandroidstudio.framework.model3D.Position3D; import org.ntlab.radishforandroidstudio.framework.model3D.Quaternion3D; import cactusServer.entities.CameraState; import cactusServer.entities.EmoteState; import cactusServer.entities.IDAddressedEntity; import cactusServer.entities.Player; import cactusServer.entities.URIAddressedEntity; import cactusServer.models.Instances; @Path("/instances/players") public class PlayersRest { @Path("/players") @POST @Produces(MediaType.APPLICATION_JSON) public URIAddressedEntity createPlayer(@PathParam("instanceId") String instanceURI, @FormParam("characterURI") String characterURI, @FormParam("cameraState") CameraState cameraState, @FormParam("animationClassToStart") EmoteState.EmoteType animationClassToStart) { Instances instances = Instances.getInstance(); IDAddressedEntity ae = instances.createPlayer(instanceURI, characterURI, cameraState, animationClassToStart); return new URIAddressedEntity((InstancesRest.INSTANCES_URI + "/" + instanceURI + "/players/" + ae.getId()), ae.getBody()); } @Path("/{playerId}") @GET @Produces(MediaType.APPLICATION_JSON) public Player getPlayer(@PathParam("instanceId") String instanceId, @PathParam("playerId") String playerId) { Instances instances = Instances.getInstance(); if (instances != null) { return instances.getPlayer(playerId); } return null; } @Path("/players/{playerId}") @PUT @Produces(MediaType.APPLICATION_JSON) public Player updatePlayer(@PathParam("instanceId") String instanceId, @FormParam("playerId") String playerId, @FormParam("characterURI") String characterURI, @FormParam("position") Position3D position, @FormParam("angle") Quaternion3D angle, @FormParam("cameraState") CameraState cameraState, @FormParam("animationClassToStart") EmoteState.EmoteType animationClassToStart) { return Instances.getInstance().updatePlayer(playerId, characterURI, position, angle, cameraState, animationClassToStart); } }