交易数量
我需要多个交易。但 Bada 只允许我进行一笔交易。如何增加交易数量?我正在使用的代码是
result HttpClient::TestHttpGet(Osp::Base::String link1)
{
int r1;
result r = E_SUCCESS;
HttpTransaction* pTransaction = null;
HttpRequest* pRequest = null;
String hostAddr(link1);
if(__pSession == null)
{
__pSession = new HttpSession();
r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
if (IsFailed(r))
goto CATCH;
}
pTransaction = __pSession->OpenTransactionN();
r1=__pSession->GetActiveTransactionCount();
AppLog("Total no of transaction:%d",r);
if (null == pTransaction)
{
r = GetLastResult();
goto CATCH;
}
r = pTransaction->AddHttpTransactionListener(*this);
if (IsFailed(r))
goto CATCH;
pRequest = const_cast<HttpRequest*>(pTransaction->GetRequest());
if(pRequest == null)
{
r = GetLastResult();
goto CATCH;
}
r = pRequest->SetUri(link1);
if(IsFailed(r))
goto CATCH;
r = pRequest->SetMethod(NET_HTTP_METHOD_GET);
if(IsFailed(r))
goto CATCH;
r = pTransaction->Submit();
if(IsFailed(r))
goto CATCH;
return r;
CATCH:
return r;
}
I am in a need of multiple Transaction. But Bada is allowing me to do only one transaction. How to increase the number of Transaction? The code which i am using is
result HttpClient::TestHttpGet(Osp::Base::String link1)
{
int r1;
result r = E_SUCCESS;
HttpTransaction* pTransaction = null;
HttpRequest* pRequest = null;
String hostAddr(link1);
if(__pSession == null)
{
__pSession = new HttpSession();
r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
if (IsFailed(r))
goto CATCH;
}
pTransaction = __pSession->OpenTransactionN();
r1=__pSession->GetActiveTransactionCount();
AppLog("Total no of transaction:%d",r);
if (null == pTransaction)
{
r = GetLastResult();
goto CATCH;
}
r = pTransaction->AddHttpTransactionListener(*this);
if (IsFailed(r))
goto CATCH;
pRequest = const_cast<HttpRequest*>(pTransaction->GetRequest());
if(pRequest == null)
{
r = GetLastResult();
goto CATCH;
}
r = pRequest->SetUri(link1);
if(IsFailed(r))
goto CATCH;
r = pRequest->SetMethod(NET_HTTP_METHOD_GET);
if(IsFailed(r))
goto CATCH;
r = pTransaction->Submit();
if(IsFailed(r))
goto CATCH;
return r;
CATCH:
return r;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您最多可以同时拥有六个会话 (HttpSession)。每个会话可以启动多个事务 (HttpTransaction),但只能按顺序启动。
我的建议:如果您需要连接到不同的主机,请使用多个会话。但对于每个主机,一次仅使用一个事务。如果您尝试与同一主机建立多个连接,您的速度不会更快(请记住您使用的手机网络带宽有限,必须在并行连接之间共享)。
You can have up to six simultaneous Session (HttpSession). Each session can start several transactions (HttpTransaction) but only sequentially.
My advice: use several sessions if you need to connect to different hosts. But for each host, use only one transaction at a time. You won't go faster if you try to make several connection to the same host (remember you are on a phone with limited network bandwith which has to be shared between parallel connections).
您还可以尝试 NET_HTTP_SESSION_MODE_PIPELINE 在会话中管道事务。
you can also try NET_HTTP_SESSION_MODE_PIPELINE to pipeline transactions within a session.