Search in sources :

Example 1 with GetMapObjectsResponse

use of POGOProtos.Networking.Responses.GetMapObjectsResponseOuterClass.GetMapObjectsResponse in project PokeGOAPI-Java by Grover-c13.

the class Map method requestMapObjects.

/**
	 * Requests and returns MapObjects from the server.
	 *
	 * @return the returned MapObjects
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
protected MapObjects requestMapObjects() throws RequestFailedException {
    List<Long> cells = getDefaultCells();
    GetMapObjectsMessage.Builder builder = GetMapObjectsMessage.newBuilder();
    builder.setLatitude(api.getLatitude());
    builder.setLongitude(api.getLongitude());
    for (Long cell : cells) {
        builder.addCellId(cell);
        builder.addSinceTimestampMs(0);
    }
    ServerRequest request = new ServerRequest(RequestType.GET_MAP_OBJECTS, builder.build());
    api.getRequestHandler().sendServerRequests(request, true);
    try {
        GetMapObjectsResponse response = GetMapObjectsResponse.parseFrom(request.getData());
        MapObjects mapObjects = new MapObjects(api);
        for (MapCell cell : response.getMapCellsList()) {
            mapObjects.addCell(cell);
        }
        return mapObjects;
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) GetMapObjectsResponse(POGOProtos.Networking.Responses.GetMapObjectsResponseOuterClass.GetMapObjectsResponse) ServerRequest(com.pokegoapi.main.ServerRequest) GetMapObjectsMessage(POGOProtos.Networking.Requests.Messages.GetMapObjectsMessageOuterClass.GetMapObjectsMessage) MapCell(POGOProtos.Map.MapCellOuterClass.MapCell)

Aggregations

MapCell (POGOProtos.Map.MapCellOuterClass.MapCell)1 GetMapObjectsMessage (POGOProtos.Networking.Requests.Messages.GetMapObjectsMessageOuterClass.GetMapObjectsMessage)1 GetMapObjectsResponse (POGOProtos.Networking.Responses.GetMapObjectsResponseOuterClass.GetMapObjectsResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1