Hi,
I have tried to replicate the issue but unfortunately I have not seen any crash.
My test is made of a class declared in a .H file
Code: Select all
class CMyTest
{
public:
void connectToSfs();
private:
boost::shared_ptr<Sfs2X::SmartFox> smartfoxServer;
};
and implemented in a .cpp file
Code: Select all
void CMyTest::connectToSfs()
{
smartfoxServer = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox(true));
smartfoxServer->ThreadSafeMode(true);
std::string cfFile = ".\\Configuration\\sfs-config.xml";
// I remove the below statement because I have not cocos2d
// auto cf = cocos2d::FileUtils::getInstance()->fullPathForFilename(cfFile);
smartfoxServer->LoadConfig(cfFile, true);
}
In connectToSfs method I have copied your code, removing only the call to cocos2d::FileUtils::getInstance()->fullPathForFilename
because I have not cocos2d at the moment on my Pc.
Instead of cocos2d::FileUtils::getInstance()->fullPathForFilename I have set the cfFile string with an appropriate value
Could you give me additional information about the call to connectToSfs method in your context where the crash occurs?
May be that in your context, the smartfoxServer smart pointer goes out of scope while LoadConfig is working?
Could you compare your code with our SimpleChat sample?
In SimpleChat sample you can see the declaration of a SmartFox pointer in MainFrm.h (at the end of the file)
Code: Select all
boost::shared_ptr<Sfs2X::SmartFox> m_ptrSmartFox;
and the establishment of the connection with SmartFox Server in MainFrm.cpp
Code: Select all
void CMainFrame::InitializeSmartFox()
{
// Initialize Smart Fox
m_ptrSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox(true));
m_ptrSmartFox->ThreadSafeMode(false);
...
m_ptrSmartFox->LoadConfig(".\\Configuration\\sfs-config.xml", true);
}