交易数量

发布于 2024-09-28 22:56:06 字数 1110 浏览 3 评论 0原文

我需要多个交易。但 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╭ゆ眷念 2024-10-05 22:56:06

您最多可以同时拥有六个会话 (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).

心不设防 2024-10-05 22:56:06

您还可以尝试 NET_HTTP_SESSION_MODE_PIPELINE 在会话中管道事务。

you can also try NET_HTTP_SESSION_MODE_PIPELINE to pipeline transactions within a session.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文