Languages

Menu
Sites
Language
httprequest on serviceapp.

hello,

when i use httprequest api on serviceapp. it looks like is doesn't work.  (exactly,  pTransaction->Submit();)

IHttpTransactionEventListener doesn't receive any event.

 

of course. httpclient sample app. works well.

also when i write abour httprequest api on application has a ui, the api, listener works well.

but, it doesn't works on service app.

i suspend that httprequest api should be used in the form has a ui??

 

is there any example the source code about httprequest on serviceapp??

 

 

below is my source code

================================

 
using namespace Tizen::Base;
using namespace Tizen::Net::Http;
 
#define TAG "TEST"
 
 
BrowserUtil::BrowserUtil() {
// TODO Auto-generated constructor stub
 
}
 
BrowserUtil::~BrowserUtil() {
// TODO Auto-generated destructor stub
}
 
 
 
result
BrowserUtil::TestHttpTransaction(void)
{
    result r = E_SUCCESS;
 
    HttpSession* pSession = null;
    HttpTransaction* pTransaction = null;
    String* pProxyAddr = null;
    String hostAddr(L"http://www.tizen.org");
 
    pSession = new HttpSession();
    r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr ,hostAddr, null);
 
    // Open a new HttpTransaction.
    pTransaction = pSession->OpenTransactionN();
 
    r = pTransaction->AddHttpTransactionListener(*this);
 
    HttpRequest* pRequest = pTransaction->GetRequest();
    r = pRequest->SetUri(L"http://www.tizen.org");
    r = pRequest->SetMethod(NET_HTTP_METHOD_GET);
 
    // Submit the HttpTransaction.
    r = pTransaction->Submit();
 
    Tizen::Base::Runtime::Thread::Sleep(2 * 30 * 1000);
 
    return r;
}
 
 
void
BrowserUtil::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen)
{
AppLogTag(TAG,"OnTransactionReadyToRead");
 
HttpResponse* pHttpResponse = httpTransaction.GetResponse();
if (pHttpResponse->GetHttpStatusCode() == HTTP_STATUS_OK)
{
HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
if (pHttpHeader != null)
{
AppLogTag(TAG, "availableBodyLen : %d",availableBodyLen);
}
}
}
 
void
BrowserUtil::OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r)
{
AppLogTag(TAG,"OnTransactionAborted(%s)", GetErrorMessage(r));
 
delete &httpTransaction;
}
 
void
BrowserUtil::OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize)
{
AppLogTag(TAG,"OnTransactionReadyToWrite");
}
 
void
BrowserUtil::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool authRequired)
{
AppLogTag(TAG,"OnTransactionHeaderCompleted");
}
 
void
BrowserUtil::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction)
{
AppLogTag(TAG,"OnTransactionCompleted");
 
delete &httpTransaction;
}
 
void
BrowserUtil::OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::String* pCert)
{
AppLogTag(TAG,"OnTransactionCertVerificationRequiredN");
 
httpTransaction.Resume();
 
delete pCert;
}
 
 
Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

1 Replies
Benjamin Blois
There is a little limitation in Tizen : you can't really sleep the main thread, as there is no screen update and no events are received while sleeping (actually, it must get out of your functions to have all this working). If you want to do repetitive tasks, use a timer, which will allow the callbacks to be call between two passages in the timer function.