当前位置: 首页>>代码示例>>C++>>正文


C++ Http::Update方法代码示例

本文整理汇总了C++中Http::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Http::Update方法的具体用法?C++ Http::Update怎么用?C++ Http::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Http的用法示例。


在下文中一共展示了Http::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: not_main

int not_main(int argc, char *argv[])
{
  Http http;

//  HttpRequest *request1 = new HttpRequest("http://www.google.com");
  //http.AddRequest(request1);

//  HueLightResponse *request2 = new HueLightResponse("http://10.0.2.227/api/huelibrary/lights");
 // http.AddRequest(request2);

//HueLightResponse *IPAddr= new HueLightResponse("https://www.meethue.com/api/nupnp");
//http.AddRequest(IPAddr);

//  HttpRequest *request3 = new HueLightResponse("http://10.0.2.227/api/huelibrary/lights/1/state","{ \"on\": false, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");
 // http.AddRequest(request3);

  //HttpRequest *request = new HttpRequest("http://10.0.2.227/api/huelibrary/lights/3/state","{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");

//  http.AddRequest("http://www.google.com");
//  http.AddRequest("http://10.0.2.227/api/huelibrary/lights/3/state","{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");
  //http.AddRequest("http://10.0.2.227/");
 // http.AddRequest("http://10.0.2.227/api/huelibrary/lights");

  while (1)
  {
fprintf(stderr,"inside loop\n");
  // In some update loop called each frame
  http.Update();
  http.Status();
   sleep(1);
  }

 return 0;
}
开发者ID:alanswx,项目名称:afLib,代码行数:34,代码来源:hueSample.cpp

示例2: main


//.........这里部分代码省略.........
    
        timespec sleep_time;
        timespec remaining;
        sleep_time.tv_sec=0;
        sleep_time.tv_nsec=250000;
        nanosleep(&sleep_time,&remaining);
         /* check for E_INTR? and call again? */
	gpio_set_value(reset_line,1);

        while (1) {
                counter++;
                memset((void*)fdset, 0, sizeof(fdset));

                fdset[0].fd = STDIN_FILENO;
                fdset[0].events = POLLIN;

                fdset[1].fd = gpio_fd;
                fdset[1].events = POLLPRI;

                lseek(gpio_fd, 0, SEEK_SET);    /* consume any prior interrupt */
                read(gpio_fd, buf, sizeof (buf));


                rc = poll(fdset, nfds, timeout);

                if (rc < 0) {
                        printf("\npoll() failed!\n");
                        return -1;
                }

                if (rc == 0) {
                        printf(".");
                }

                if (fdset[1].revents & POLLPRI) {
                        len = read(fdset[1].fd, buf, MAX_BUF);
                        printf("\npoll() GPIO %d interrupt occurred\n", interrupt_line);
                lseek(gpio_fd, 0, SEEK_SET);    /* consume interrupt */
                read(gpio_fd, buf, sizeof (buf));

                        theLib->mcuISR();
                }

                if (fdset[0].revents & POLLIN) {
                        (void)read(fdset[0].fd, buf, 1);
                        //printf("\npoll() stdin read 0x%2.2X\n", (unsigned int) buf[0]);
                }



		switch (state)
		{
		   case HUE_STATE_NEED_IP:
			// we need to check and see if we have an IP, then we can switch
  			if (IPAddr->completed())
{
                          state = HUE_STATE_HAS_IP;
                          IPAddr->get_ip(hue_ip);
                        fprintf(stderr,"IP: %s\n",hue_ip);
			sprintf(hue_prefix,"http://%s/api/huelibrary/",hue_ip);
                        state = HUE_STATE_HAS_IP;
}
			break;
		   case HUE_STATE_HAS_IP:

                // every so many loops check and start the lights query to update the lights..
		if (counter % 100 == 0)
                {
                   //check to see how many HTTP requests are outstanding
                   if (hueLightResponder == NULL)
                   { 
printf("****initializing new request to get the lights\n");
                      char hue_request[1024];
                      sprintf(hue_request,"%slights",hue_prefix);
                      hueLightResponder =  new HueLightResponse(hue_request,theLib);
                      http.AddRequest(hueLightResponder);
                   }
                   else if (hueLightResponder->completed())
                   {
                      delete hueLightResponder;
                      char hue_request[1024];
                      sprintf(hue_request,"%slights",hue_prefix);
                      hueLightResponder =  new HueLightResponse(hue_request,theLib);
                      http.AddRequest(hueLightResponder);
                   }
                  

                }

                }

  	http.Update();
  	http.Status();
        theLib->loop();
        fflush(stdout);
        }

    gpio_fd_close(gpio_fd);
   return 0;
}
开发者ID:alanswx,项目名称:afLib,代码行数:101,代码来源:hueSample.cpp


注:本文中的Http::Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。