var HttpRequest=256;
var Frame=0; 
 
function finishedRequest(dataReceived)
{
  //print("finished request! Data size:" + dataReceived.length);
  //print("contains:[" + dataReceived+"]");
  if (dataReceived.search("1")!=-1) {
	cube = ccbGetSceneNodeFromName("Light1");	
	ccbSetSceneNodeProperty(cube, "Color", new vector3d(1, 0, 0));
  }
  if (dataReceived.search("2")!=-1) {
	cube = ccbGetSceneNodeFromName("Light1");	
	ccbSetSceneNodeProperty(cube, "Color", new vector3d(1, 1, 1));
  }
  if (dataReceived.search("3")!=-1) {
	cube = ccbGetSceneNodeFromName("Light2");	
	ccbSetSceneNodeProperty(cube, "Color", new vector3d(0, 1, 0));
  }
  if (dataReceived.search("4")!=-1) {
	cube = ccbGetSceneNodeFromName("Light2");	
	ccbSetSceneNodeProperty(cube, "Color", new vector3d(1, 1, 1));
  }  
}

function onFrameDrawing()
{
	if (Frame==100) {
		HttpRequest=ccbDoHTTPRequest("http://192.168.1.24/", finishedRequest);
		Frame=0;
	} else { Frame++; }
	if (HttpRequest==0) {
		//
	}
   
}

ccbRegisterOnFrameEvent(onFrameDrawing);