public int setAsReceiver(int i) {
		if (i < 0 || i >= agents.size() || (destination == getPeerAgentAt(i)))
			return -2;

		int ret = -1;

		if (destination != null) {
			// Restore previous receiver's GeoDevice to random waypoint.
			int j = agents.indexOf(destination);
			agents.set(j, new PeerAgent(destination.getPeer(), env, new RandomWaypointGeoDevice(destination.getPeer().getLocation(), destination.getPeer().getVelocity(), mapDim)));
			peerList.refresh(j);
			ret = j;
		}

		// Make new receiver's GeoDevice stationary.
		GeoVelocity stationary = new GeoVelocity();
		getPeerAgentAt(i).getPeer().setVelocity(stationary);
		agents.set(i, new PeerAgent(getPeerAgentAt(i).getPeer(), env, new DefaultGeoDevice(getPeerAgentAt(i).getPeer().getLocation(), stationary)));
		destination = getPeerAgentAt(i);

		refresh();

		return ret;
	}