Auto disconnect | developer.brewmp.com Auto disconnect | developer.brewmp.com

Developer

Auto disconnect

Forums:

Everytime I receive a string from server, I will call Restore_Start to send out a response to server. However, after I call Restore_Start for more than 28 times, it will auto disconnect. May I know what is the problem? How many times the CALLBACK_Init(&pwa->cb, GotResp, pwa) or the Restore_Start can be called?

static void Restore_Start(WebAction *pwa)
{
ISourceUtil *pisu =NULL;
brewclient *pMe = pwa->pParent;
IWebUtil *p_IWebUtil = NULL;
int pcInLen;
char *szURL = NULL;
char *header = NULL;
pMe->data_restore = NULL;

pMe->m_nState=STATE_PROCESS;
pMe->process = 4;

if(pMe->status==2)
{
header = "BREW&24&"; // BREW&20
ND_Print(pMe, "Start Restore...\n");
}

szURL = "http://127.0.0.1/servlet/syncAppServlet";

pcInLen = 200;
pMe->data_restore = MALLOC(pcInLen);
pMe->data_restore = STRCAT(pMe->data_restore, header);
pMe->data_restore = STRCAT(pMe->data_restore,"&");
pMe->data_restore = STRCAT(pMe->data_restore, pMe->mobile);
pMe->data_restore = STRCAT(pMe->data_restore,"&");
pMe->data_restore = STRCAT(pMe->data_restore,pMe->password);
pMe->data_restore = STRCAT(pMe->data_restore,"&");

if (pMe->phoneCount > 140)
ND_Print(pMe, "Data: %s\n", pMe->data_restore, NULL, TRUE);

if (SUCCESS == ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_WEBUTIL, (void **)&p_IWebUtil ))
{
pwa->pszPostData = pMe->data_restore;

IWEBUTIL_Release(p_IWebUtil);
p_IWebUtil = NULL;
}

if (SUCCESS == ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_SOURCEUTIL, (void **)&pisu))
{

ISOURCEUTIL_PeekFromMemory(pisu, pwa->pszPostData,
STRLEN(pwa->pszPostData), 0, 0,
&pwa->pipPostData);
ISOURCEUTIL_Release(pisu);
}

CALLBACK_Init(&pwa->cb, GotResp, pwa);

if ((IPeek *)0 != pwa->pipPostData) {
IWEB_GetResponse(pMe->m_pIWeb,
(pMe->m_pIWeb, &pwa->piWResp, &pwa->cb, szURL,
WEBOPT_HANDLERDATA, pwa,
WEBOPT_HEADER, "X-Method: POST\r\n",
WEBOPT_METHOD, "POST",
WEBOPT_BODY, pwa->pipPostData,
WEBOPT_CONTENTLENGTH, STRLEN(pwa->pszPostData),
WEBOPT_END));
}

static void GotResp(void *p)
{
FOR_ALL_WEBACTIONS(pMe, p, Restore_Start(p) );