/************************************************************************************ * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University * All rights reserved. * Refer to LICENSE for terms and conditions of use. ***********************************************************************************/ package vnsim.applications.vitp.services; import java.util.*; import vnsim.applications.trafficview.SimulatedCarInfo; import vnsim.applications.vitp.utils.*; import vnsim.core.*; public class VehicleTraffic extends Service { //this is an example of a service SimulatedCarInfo info; public VehicleTraffic(SimulatedCarInfo info) { this.info=info; } public VITPRequest satisfy(VITPRequest req, HashMap params) { //takes the request, reduces the count field in the URI, and adds a line //in the message body, of the type "speed=40"; //params is a map of parameters of the local node (among them should be 'speed') System.out.println("VehicleTraffic modifying a request!"); double speed=info.getSpeed(); try{ VITPRequest request=(VITPRequest) req; req.addToBody("speed="+speed); //reduce cnt by one Vector rcs=URIParser.getRCExpressions(request.getURI()); if(rcs==null) return req; for(int i=0;i