Problem with thread when porting game to windows phone 8

@dungmv wrote:

i have used this code for httpclient wp8
https://github.com/martell/cocos2d-x/blob/curlwinrt/extensions/network/HttpClient.cpp

Hi, Do you have compiled libcurl in release?

bye

set the properties of c++ the same as debug’s, like precompiler or include paths…

@chenjc wrote:

set the properties of c++ the same as debug’s, like precompiler or include paths…

I have tried it… but doesn’t works :frowning:

you can check at this pr: https://github.com/cocos2d/cocos2d-x/pull/5835, or use https://github.com/cocos2d/cocos2d-x/pull/5098.

I used https://github.com/martell/libcurl-winrt for libcurl

@chenjc wrote:

you can check at this pr: https://github.com/cocos2d/cocos2d-x/pull/5835, or use https://github.com/cocos2d/cocos2d-x/pull/5098.

Thanks!!! now I have a crash here:

void CCHttpClient::dispatchResponseCallbacks(float delta)
{
...
    if (response)
    {
        --s_asyncRequestCount;
        
        CCHttpRequest *request = response->getHttpRequest();
        CCObject *pTarget = request->getTarget();
        SEL_HttpResponse pSelector = request->getSelector();

        if (pTarget && pSelector) 
        {
            (pTarget->*pSelector)(this, response);
        }
        
===>    response->release();
    }
}

because response is a bad pointer:

  •   response	0x6c01b2f9 {TinyGhostComponent.dll!frw::platform::onHttpRequestCompletedGET(cocos2d::extension::CCHttpClient *, cocos2d::extension::CCHttpResponse *)} {...}	cocos2d::extension::CCHttpResponse *
    
  •   cocos2d::CCObject	{m_uID=1057690866 m_nLuaID=-1895830288 m_uReference=1866887088 ...}	cocos2d::CCObject
    
  •   _pHttpRequest	0x90330ce9 {_requestType=??? _url= _requestData={ size=??? } ...}	cocos2d::extension::CCHttpRequest *
      _succeed	true (70)	bool
    
  •   _responseData	{ size=-391147512 }	std::vector<char,std::allocator<char> >
    
  •   _responseHeader	{ size=-999952885 }	std::vector<char,std::allocator<char> >
      _responseCode	537148657	int
    
  •   _errorBuffer	<Error reading characters of string.>	std::basic_string<char,std::char_traits<char>,std::allocator<char> >
    

:frowning:

I found Ms OPEN TECH create a network branch too, and we may use his branch in the near future, you had better change to: https://github.com/MSOpenTech/cocos2d-x/tree/wp8-network. Because I test network ok in 3.0, so we will use it. Thanks.

#include<thread> using namespace std; typedef thread* pthread_t; int pthread_create (pthread_t * tid, const void * attr,void *(*start) (void *),void *arg){ *tid=new thread(start,arg); return 0; } int pthread_cancel (pthread_t thread){ thread->detach(); delete thread; return 0; }