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


C++ Http类代码示例

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


在下文中一共展示了Http类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: bufferevent_get_output

void Http::write_cb(bufferevent *bev, void *ctx)
{
	Http* http = (Http*)ctx;
	evbuffer *output = bufferevent_get_output(bev);
	if(http->get_all_send() && 
			evbuffer_get_length(output) == 0)
	{
		DEBUG_LOG("empty");
		Http::release(&http);
	}
}
开发者ID:jinchaoh,项目名称:Scallop,代码行数:11,代码来源:Http.cpp

示例3: sprintf_s

//送信
void Result::Send() {
	Song *song = songs->GetSong(songs->GetNowSong());
	//曲IDのリクエスト作成
	char songReq[126] = { 0 };
	sprintf_s(songReq, 126, "song=%d", song->GetSongId());
	//ユーザーIDのリクエスト作成
	char userReq[32] = { 0 };
	sprintf_s(userReq, 32, "user=%s", user->GetUserId());
	//現在時刻の取得
	int temp[5] = { 0 };
	GetNowTime(temp);
	//年月日のリクエスト作成
	char dateReq[32] = { 0 };
	sprintf_s(dateReq, 32, "date=%02d-%02d-%02d %02d-%02d", temp[0], temp[1], temp[2], temp[3], temp[4]);
	//総合得点のリクエスト作成
	char totalReq[16] = { 0 };
	sprintf_s(totalReq, 16, "total=%d", this->total);
	//区間別採点のリクエスト作成
	char partReq[64] = { 0 };
	sprintf_s(partReq, 64, "part=%d", score[0]);
	for (int i = 1, n = this->max; i < n; i++) {
		sprintf_s(partReq, 64, "%s/%d", partReq, score[i]);
	}
	//体の部位採点のリクエスト作成
	char bodyPoint[4] = { 0 };
	for (int i = 0; i < 4; i++) {
		switch (point[i]) {
		case 1:bodyPoint[i] = 'A';	break;
		case 2:bodyPoint[i] = 'B';	break;
		case 3:bodyPoint[i] = 'C';	break;
		}
	}
	char bodyReq[32] = { 0 };
	sprintf_s(bodyReq, 32, "body=%c/%c/%c/%c", bodyPoint[0], bodyPoint[1], bodyPoint[2], bodyPoint[3]);
	//タイミングのリクエスト作成
	char timingReq[16] = { 0 };
	sprintf_s(timingReq, 16, "timing=%d", timing);
	//表情のリクエスト作成
	char expressionReq[16] = { 0 };
	sprintf_s(expressionReq, 16, "expression=%d", expression);
	//コメントのリクエスト作成
	WCHAR w_comment[256] = { 0 };
	mbstowcs(w_comment, comment, 256);
	char commentReq[256] = { 0 };
	sprintf_s(commentReq, 256, "comment=%s", w_comment);

	//urlを作成
	char url[512] = { 0 };
	sprintf_s(url, 512, "http://globalstudios.jp/mai-archive/api_add.php?%s&%s&%s&%s&%s&%s&%s&%s&%s", 
		songReq, userReq, dateReq, totalReq, partReq, bodyReq, timingReq, expressionReq, commentReq);
	Http http;
	if(!http.Send(url))printfDx("httpエラー");
}
开发者ID:Kousuke-N,项目名称:Mai-Kagami,代码行数:54,代码来源:Result.cpp

示例4: main

int main(int argc, char *argv[]) {
	Main app(APP_SOCKETS);
	Http http;
	app.open(argc,argv);
	http.setUserAgent("Http Class User-Agent, v.0.1");

	http.get("www.google.com","");

	const char *fn = "http.txt";
	FILE *fp = fopen(fn,"wb");
	if(fp) {
		fwrite(http.getFile(),http.getFileSize(),1,fp);
		fclose(fp);
	} else perror(fn);
	return 0;
}
开发者ID:NikitaSharma28,项目名称:libamanita,代码行数:16,代码来源:http.cpp

示例5: main

int main(int argc, const char * argv[])
{

    Http *http = new Http ( "GET / HTTP/1.1"
                            "Host: host.com"
                            "User-Agent: Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7"
                            "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8"
                            "Accept-Language: pl,en-us;q=0.7,en;q=0.3"
                            "Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7"
                            "Keep-Alive: 300"
                            "Connection: keep-alive");
    
    std::cout<<http->getHost()<<"\n";
    
    
    return 0;
}
开发者ID:unix-rules,项目名称:http-cpp,代码行数:17,代码来源:main.cpp

示例6: DEBUG_LOG

void Http::read_cb(bufferevent *bev, void *ctx)
{
	DEBUG_LOG("read");
	Http* http = (Http*)ctx;

	if(http->bev == bev)
	{
		while(http->loop());	
	}
	else if(http->bev_cgi == bev)
	{
		evbuffer_add_buffer(bufferevent_get_output(http->bev), bufferevent_get_input(bev));
	}
	else
	{
		DEBUG_LOG("error read_cb");	
	}
}
开发者ID:jinchaoh,项目名称:Scallop,代码行数:18,代码来源:Http.cpp

示例7: stream

void Http::download ( const std::string &url, const std::string &file, unsigned int timeoutMilliSeconds, Unknown *caller )
{
  // Open file.
  std::ofstream stream ( file.c_str(), std::ofstream::binary | std::ofstream::out );
  if ( false == stream.is_open() )
  {
    throw std::runtime_error ( "Error 2742979881: Failed to open file '" + file + "' for writing" );
  }
 
  // This will remove the file is there's an exception.
  Usul::Scope::RemoveFile removeFile ( file );
  
  Http http ( url, &stream, caller );
  http.download( timeoutMilliSeconds );
  
  // Keep the file.
  removeFile.remove ( false );
}
开发者ID:gideonmay,项目名称:minervagis,代码行数:18,代码来源:Http.cpp

示例8: EVUTIL_SOCKET_ERROR

void Http::event_cb(bufferevent *bev, short events, void *ctx)
{
	if (events & BEV_EVENT_ERROR)
	{
		int err = EVUTIL_SOCKET_ERROR();

		if (err)
		{
			DEBUG_LOG("Socket error: %s\n", evutil_socket_error_to_string(err));
		}
	}

	if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR))
	{
		Http* http = (Http*) ctx;

		if(http->bev_cgi == bev)
		{
			evbuffer *output = bufferevent_get_output(http->bev);
			if(evbuffer_get_length(output) == 0)
			{
				DEBUG_LOG("release http");
				Http::release(&http);	
			}
			else
			{
				DEBUG_LOG("release unix");
				http->set_all_send(true);
				bufferevent_free(http->bev_cgi);
				http->bev_cgi = NULL;
			}	
		}
		else if(http->bev == bev)
		{
			DEBUG_LOG("release http");
			Http::release(&http);
		}
		else
		{
			DEBUG_LOG("error event_cb");	
		}
	}
}
开发者ID:jinchaoh,项目名称:Scallop,代码行数:43,代码来源:Http.cpp

示例9: workingStarted

void PluginTester::run()
{
	stopFlag = false;
    failed = 0;

	emit workingStarted();

	for (int n = 0; n < tests->count(); n++)
	{
		PluginTest *test = tests->at(n);
		//
        if ((onlyFailed && test->isTestOk()) || (onlySelected != -1 && n != onlySelected)) continue;
		//
		emit pluginTestRunning(test);
		// get video information
        emit workingProgress(n * 2, tests->count() * 2, QString("Getting <b>%1</b> video information... [1/2]").arg(test->getPluginTitle()));
		VideoInformationPlugin *plugin = new VideoInformationPlugin(NULL, pluginsDir + test->getPluginFile());
		VideoDefinition  vd = plugin->getVideoInformation(test->getUrl());
		// try to download video
		emit workingProgress(n * 2 + 1, tests->count() * 2, QString("Testing <b>%1</b> video download... [2/2]").arg(test->getPluginTitle()));
		Http *http = new Http();
		if (!vd.cookies.isEmpty()) http->addCookies(vd.cookies);
		if (!vd.headers.isEmpty()) http->addHeaderParameters(vd.headers);
		int contentLength = copyBetween(http->head(QUrl(vd.URL)), "Content-Length: ", "\n").toInt();
		delete http;
		// update test info
		test->setCaption(vd.title);
		test->setFlvUrl(vd.URL);
		test->setSize(contentLength);
		// increase failed tests
		if (!test->isTestOk()) failed++;
		// destroy plugin
		delete plugin;
		// finished
		emit pluginTestFinished(test);
		// small pause, prevent 100% cpu
		if (stopFlag) n = tests->count(); else sleep(1);
	}

	emit workingFinished(tests->count() - failed, failed);
}
开发者ID:xVST,项目名称:xVideoServiceThief,代码行数:41,代码来源:plugintester.cpp

示例10: main

int main(int argc, char **argv)
{
  Http http;
  char *page = NULL;
  size_t size = 0;

  for (int i = 1; i < argc; ++i) {
    cerr << "== GET '" << argv[i] << "' ==" << endl;
    
    try {
      //http.set_verbose(true);
      int code = http.get(page, size, argv[i]);
      if (page) delete[] page;

      const Http::Headers &hdrs = http.get_headers();

      Http::Headers::const_iterator it;
      const char *loc = http.get_recv_header("location");
      const char *coo = http.get_recv_header("set-cookie");
      const char *len = http.get_recv_header("content-length");
    
      cerr << "== code = " << code << endl;
      cerr << "== headers size = " << hdrs.size() << endl;
      cerr << "== location = " << (loc?loc:"?") << endl;
      cerr << "== set-cookie = " << (coo?coo:"?") << endl;
      cerr << "== content-length = " << (len?len:"?") << " (strona: " << size << ")"<< endl;
    } 
    catch (Exception &e) {
      cerr << "== exception: " << e.what() << endl;
    }
  }

  return 0;
}
开发者ID:truszkowski,项目名称:librs,代码行数:34,代码来源:test_http.cpp

示例11: main

int main(int argc, char const *argv[]) {
	Http http;
	stringstream ss;
	// See Web Service source file in https://github.com/JAlikhani/BooksWebServiceNodeJS
	// Web service temporarily deployed in Heroku
	// Output JSON file looks like:
	/*
	 {
		   "book": [

		      {
		         "id":"01",
		         "title": "In Search of Lost Time",
		         "author": "Marcel Proust"
		      },

		      {
		         "id":"02",
		         "title": "Moby Dick",
		         "author": "Herman Melville"
		      },

		      {
		         "id":"03",
		         "title": "Hamlet",
		         "author": "William Shakespeare"
		      },

		      {
		         "id":"04",
		         "title": "The Odyssey",
		         "author": "Homer"
		      }
		   ]
		}
	 */
	ss << http.Request("floating-fjord-16663.herokuapp.com", 80, "/books", "application/json");
	JSONParser jsonParser(ss.str());
	cout << jsonParser.Books();
}
开发者ID:JAlikhani,项目名称:BasicRestfulServiceCPP14,代码行数:40,代码来源:BasicRestfulServiceCPP.cpp

示例12: get_info

int HttpPlugin::get_info(Task *task) {
    Http http;

    http.set_timeout(task->timeout);
    http.set_log(&debug_log);
#ifdef HAVE_SSL
    if (task->url.get_protocol() == HTTPS) {
        http.set_use_ssl(true);
    }
#endif

    if (task->url.get_user() != NULL) {
        http.auth(task->url.get_user(),
                task->url.get_password() ? task->url.get_password() : "");
    }

    if (task->get_referer() != NULL) {
        http.header("Referer", task->get_referer());
    } else {
        http.header("Referer", task->url.get_url());
    }

    if (task->fileSize > 0) {
        // test the Range
        http.set_range(1);
    }

    if (task->proxy.get_type() == HTTP_PROXY) {
        if (task->proxy.get_host() == NULL) {
            return -1;
        }
        if (http.connect(task->proxy.get_host(), task->proxy.get_port()) < 0) {
            return -2;
        }
        http.set_host(task->url.get_host(), task->url.get_port());
        if (task->proxy.get_user() != NULL) {
            http.proxy_auth(task->proxy.get_user(),
                    task->proxy.get_password() ? task->proxy.get_password() : "");
        }

        if (http.get(task->url.get_url()) < 0) {
            return -2;
        }
    } else {
        if (http.connect(task->url.get_host(), task->url.get_port()) < 0) {
            return -2;
        }
        if (http.get(task->url.get_encoded_path()) < 0) {
            return -2;
        }
    }

    if (http.parse_header() < 0) return -2;
    switch (http.get_status_code()) {
        case 200:  // HTTP_STATUS_OK
        case 206:  // HTTP_STATUS_PARTIAL_CONTENTS
        case 300:  // HTTP_STATUS_MULTIPLE_CHOICES
        case 304:  // HTTP_STATUS_NOT_MODIFIED
            break;
        case 301:  // HTTP_STATUS_MOVED_PERMANENTLY
        case 302:  // HTTP_STATUS_MOVED_TEMPORARILY
        case 303:  // HTTP_SEE_OTHER
        case 307:  // HTTP_STATUS_TEMPORARY_REDIRECT
            {  // redirect
                task->fileSize = -1;  // if not, the new location's filesize is wrong
                const char *location = http.get_header("Location");
                if (location == NULL) {
                    // I do not know when this will happen, but no harm
                    location = http.get_header("Content-Location");
                    if (location == NULL) return -1;
                }
                if (strcmp(location, task->url.get_url()) == 0) break;
                if (task->url.reset_url(location) < 0) return -2;
                return S_REDIRECT;
            }
        case 305:  // HTTP_USE_PROXY
            {   // get the content through the proxy
                task->fileSize = -1;  // if not, the new location's filesize is wrong
                return S_REDIRECT;
            }
        case 408:  // HTTP_CLIENT_TIMEOUT
        case 504:  // HTTP_GATEWAY_TIMEOUT
        case 503:  // HTTP_UNAVAILABLE
        case 502:  // HTTP_BAD_GATEWAY
            {   // these errors can retry later
                return -2;
            }
        default:
            return -1;
    }

    // if the page is an active page, we maybe can not get the filesize
    if (task->fileSize < 0) {
        task->fileSize = http.get_file_size();
        if (task->fileSize > 1) {
            // we need test whether the Range header is supported or not
            return -2;
        }
    } else {
        // IIS never return the Accept-Ranges header
//.........这里部分代码省略.........
开发者ID:cychenyin,项目名称:Mytget,代码行数:101,代码来源:httpplugin.cpp

示例13: download

int HttpPlugin::download(Task& task, Block *block) {
    block->state = STOP;
    if (task.resumeSupported) {
        if (block->downloaded >= block->size) {
            block->state = EXIT;
            return 0;
        } else {
            block->bufferFile.seek(block->startPoint + block->downloaded);
        }
    } else {
        block->bufferFile.seek(0);
        block->downloaded = 0;
    }

    Http http;
    http.set_timeout(task.timeout);
    http.set_log(&debug_log);
#ifdef HAVE_SSL
    if (task.url.get_protocol() == HTTPS) {
        http.set_use_ssl(true);
    }
#endif

    if (task.resumeSupported) {
        // the end is not set for the schedule purpose
        http.set_range(block->startPoint + block->downloaded);
    }

    if (task.url.get_user() != NULL) {
        http.auth(task.url.get_user(),
                task.url.get_password() ? task.url.get_password() : "");
    }

    if (task.get_referer() != NULL) {
        http.header("Referer", task.get_referer());
    } else {
        http.header("Referer", task.url.get_url());
    }

    if (task.proxy.get_type() == HTTP_PROXY) {
        if (http.connect(task.proxy.get_host(), task.proxy.get_port()) < 0) {
            return -2;
        }
        http.set_host(task.url.get_host(), task.url.get_port());
        if (task.proxy.get_user() != NULL) {
            http.proxy_auth(task.proxy.get_user(),
                    task.proxy.get_password() ? task.proxy.get_password() : "");
        }
        if (http.get(task.url.get_url()) < 0) {
            return -2;
        }
    } else {
        if (http.connect(task.url.get_host(), task.url.get_port()) < 0) {
            return -2;
        }
        if (http.get(task.url.get_encoded_path()) < 0) {
            return -2;
        }
    }

    if (http.parse_header() < 0) return -2;
    // the service maybe unreachable temply
    // some servers alway return 302, so nasty
    if (http.get_status_code() >= 400) return -2;

_re_retr:
    block->state = RETR;
    if (block->bufferFile.retr_data_from(&http, &block->downloaded,
                block->size - block->downloaded) < 0) {
        block->state = STOP;
        return -2;
    }

    if (task.resumeSupported && block->downloaded < block->size) {
        block->state = STOP;
        return -2;
    }

    block->state = WAIT;
    usleep(500000);
    if (block->state == WAKEUP) goto _re_retr;
    block->state = EXIT;
    return 0;
};
开发者ID:cychenyin,项目名称:Mytget,代码行数:84,代码来源:httpplugin.cpp

示例14: Http

/* Loop the readStream list, and return the already stream */
int StreamManager::HttpParseHeader(){

    WebStream *webStream = NULL;
    list<WebStream *>::iterator ite;
    
    ESLog::ISLog("HTTP HEADER SETS PARSE START\n", __FILE__, __LINE__);

    ESLog::ISLog("readStreamSize:%d\n", __FILE__, __LINE__, this->readStream.size());
    /* loop */
    for( ite = this->readStream.begin(); ite != this->readStream.end(); ++ite ) {

        int result = -1;
        webStream = *ite;

        
        ESLog::ISLog("read webStream->http ptr:%u\n", __FILE__, __LINE__, webStream->GetHttpPtr());
        ESLog::ISLog("read webStream->fd:%d\n", __FILE__, __LINE__, webStream->GetTcpConnFd());
        ESLog::ISLog("read webStream->Status:%s\n", __FILE__, __LINE__, webStream->GetStatusDesc());

        /* if the readStream has writed */
        if( webStream->GetStatus() == WSTREAM_WRITE ) {
            continue;
        }

        /* is http protocol parser exist */
        if( !webStream->IsHttpParserExist() ) {
            ESLog::ISLog("An new Http Object Create \n", __FILE__, __LINE__ );
            Http *httpParser = new Http();
            httpParser->SetWebStreamPtr(webStream);
            webStream->SetHttpParser(httpParser);
            ESLog::ISLog("New Http read webStream->http ptr:%u\n", __FILE__, __LINE__, webStream->GetHttpPtr());
        }

        ESLog::ISLog("read WebStream->HttpStatus:%s\n", __FILE__, __LINE__, webStream->GetHttpPtr()->GetStatusDesc());

        /* if the header has parserd*/
        if( webStream->GetHttpPtr()->GetStatus() == HTTP_REQHEAD_PARSED  ) {
            continue;
        }

        /* if the latest http parsed over, again init http object */
        if( webStream->GetHttpPtr()->GetStatus() == HTTP_RESSEND_OVER  ) {
            
            webStream->GetHttpPtr()->ReInit();
        }

        /* parse the http header, if the http header parsed, then we give the webStream to the
           session/application, it will send to a idle thread to tackle the session
           if return 0, the header parser over; if return > 0 , it still to parser;
           if return < 0 , there is an error happend */
        result = webStream->ParseHttpHeader();  // <--i) set the status of the webStream , http Status
        if( result < 0 ) {
            
            ESLog::ISLog("ParseHttpHeader Erorr START\n", __FILE__, __LINE__ );
            webStream->SetStatus(WSTREAM_ERROR);
            //webStream->GetHttpPtr()->SetStatus(HTTP_RESSEND_OVER);
            //Server::Instance()->GetIOLoop().ModToReadEventFd(webStream->GetTcpConnFd(), (void *)webStream);
            //webStream->ReInit();
            //this->DeleteReadWebStream(webStream);

            Server::Instance()->GetIOLoop().DelReadEventFd(webStream->GetTcpConnFd());

            //webStream->FreeTcpConn();
            //webStream->FreeHttp();
            //webStream->ReInit();
            //webStream->SetStatus(WSTREAM_UNINITILIZED);
            //this->AddIdleStream(webStream);

            ESLog::ISLog("ParseHttpHeader Erorr END\n", __FILE__, __LINE__ );
            continue;
            //break;
            //return  result;  // an error happend
        }

        /* the header has passed  */
        if( webStream->GetHttpPtr()->GetStatus() == HTTP_REQHEAD_PARSED ) {
            //webStream->GetHttpPtr()->SetStatus(2);
            ESLog::ISLog("there is http head parsed\n", __FILE__, __LINE__);
            webStream->SetStatus(WSTREAM_UNDISPATHED);
            this->AddTaskWebStream(webStream);
        }
        
    }

    ESLog::ISLog("HTTP HEADER SETS PARSE END\n", __FILE__, __LINE__);
}
开发者ID:kzhiquan,项目名称:blog-eyesee,代码行数:87,代码来源:StreamManager.cpp

示例15: onAttributeSet_callback

void onAttributeSet_callback(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value)
{
  HttpRequest *request = NULL;
  char hue_request[1024];
  fprintf(stdout,"onAttributeSet_callback: %d len: %d %x %s\n",attributeId,valueLen,*value,value);
  switch (attributeId)
  {
fprintf(stderr,"BUTTON PRESSED!\n");
break;
        case AF_LIGHT1:
          fprintf(stdout,"AF_LIGHT1 == %d\n",*value);
          sprintf(hue_request,"%slights/1/state",hue_prefix);
          if (*value)
  request = new HttpRequest(hue_request,"{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");
          else
  request = new HttpRequest(hue_request,"{ \"on\": false, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");

 http.AddRequest(request);

        break;
        case AF_LIGHT2:
          fprintf(stdout,"AF_LIGHT2 == %d\n",*value);
          sprintf(hue_request,"%slights/2/state",hue_prefix);
          if (*value)
  request = new HttpRequest(hue_request,"{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");
          else
  request = new HttpRequest(hue_request,"{ \"on\": false, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");

 http.AddRequest(request);

        break;
        case AF_LIGHT3:
          fprintf(stdout,"AF_LIGHT3 == %d\n",*value);
          sprintf(hue_request,"%slights/3/state",hue_prefix);
fprintf(stderr,"LIGHT 3 CHANGE STATE: %s\n",hue_request);
          if (*value)
  request = new HttpRequest(hue_request,"{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");
          else
  request = new HttpRequest(hue_request,"{ \"on\": false, \"hue\": 25500, \"sat\": 100, \"bri\": 100 }");

 http.AddRequest(request);

        break;
#if 0
        case AF_LIGHT1BRI:
        {
          uint16_t *light3Value= (uint16_t *) value;
          uint8_t *light3Value2= (uint8_t *) value;
          sprintf(hue_request,"%slights/1/state",hue_prefix);
          fprintf(stdout,"AF_LIGHT3 == %d %d %d\n",*value,*light3Value,*light3Value2);
          char command[512];
          
            sprintf(command, "{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": %d }",*light3Value2);
fprintf(stderr,"!!!! [%s]\n",command);
  		request = new HttpRequest(hue_request,(const char *)command);
               http.AddRequest(request);

        }
        case AF_LIGHT2BRI:
        {
          uint16_t *light3Value= (uint16_t *) value;
          uint8_t *light3Value2= (uint8_t *) value;
          sprintf(hue_request,"%slights/2/state",hue_prefix);
          fprintf(stdout,"AF_LIGHT3 == %d %d %d\n",*value,*light3Value,*light3Value2);
          char command[512];
          
            sprintf(command, "{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": %d }",*light3Value2);
fprintf(stderr,"!!!! [%s]\n",command);
  		request = new HttpRequest(hue_request,(const char *)command);
               http.AddRequest(request);

        }
#endif
        case AF_LIGHT3BRI:
        {
          uint16_t *light3Value= (uint16_t *) value;
          uint8_t *light3Value2= (uint8_t *) value;
          sprintf(hue_request,"%slights/3/state",hue_prefix);
          fprintf(stdout,"AF_LIGHT3 == %d %d %d\n",*value,*light3Value,*light3Value2);
          char command[512];
          
            sprintf(command, "{ \"on\": true, \"hue\": 25500, \"sat\": 100, \"bri\": %d }",*light3Value2);
fprintf(stderr,"!!!! [%s]\n",command);
  		request = new HttpRequest(hue_request,(const char *)command);
               http.AddRequest(request);

        }
        break;
	case AF_LIGHT1LABEL:
          {
          char *light1Label= (char *) value;
          fprintf(stdout,"bAF_LIGHT1LABEL == %s %d\n",light1Label);
          }

	case AF_LIGHT2LABEL:
          {
          char *light2Label= (char *) value;
          fprintf(stdout,"bAF_LIGHT2LABEL == %s %d\n",light2Label);
          }

//.........这里部分代码省略.........
开发者ID:alanswx,项目名称:afLib,代码行数:101,代码来源:hueSample.cpp


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