Page 1 of 1

Does C++ API work on Android and iOS?

Posted: 18 Apr 2013, 10:42
by ganquan
Does C++ API support Android and iOS?

Re: Does C++ API work on Android and iOS?

Posted: 18 Apr 2013, 15:07
by MBagnati
With C++ API we wish to create a client library that can be used on all platforms.
For this reason we have written the API using the ANSI C++
Up to now we have examples of C++ API in following environments:
- Microsoft Windows with Visual Studio 2010 and Visual Studio 2012
- Linux Ubuntu with Eclipse
In the next future we will try to check the behaviour of C++ API in other environments.
So, the answer to your question is "yes" but currently we have not tested the library neither in Android nor in iOS

Re: Does C++ API work on Android and iOS?

Posted: 22 Apr 2013, 09:34
by ganquan
When the ios and android support released probably?

Re: Does C++ API work on Android and iOS?

Posted: 22 Apr 2013, 10:18
by Bax
As MBagnati said, the API code already supports iOS and Android, even if we didn't test them directly.
Currently we don't have enough resources to test the API in all environments, as we are still completing the development.
You can test it by yourself and report issues (if any). Thank you.

Re: Does C++ API work on Android and iOS?

Posted: 23 Apr 2013, 13:10
by ganquan
i try on iOS6.1, xCode 4.6, but i blocked by a crash in boost when connect,

0x427f58: je 0x428032 ; boost::detail::thread_data_base::~thread_data_base() + 258 [inlined] std::__1::vector<std::__1::pair<boost::condition_variable*, boost::mutex*>, std::__1::allocator<std::__1::pair<boost::condition_variable*, boost::mutex*> > >::~vector() + 123 at thread.cpp:44
boost::detail::thread_data_base::~thread_data_base() + 135 at thread.cpp:44
0x427f5e: movl 4(%esi), %edi

i not familiar with boost, is any suggestion or some configure setting should attention?

Re: Does C++ API work on Android and iOS?

Posted: 23 Apr 2013, 14:24
by Lapo
Just to understand:
where you able to compile the boost libraries we ship with the API or did you download a pre-compiled version for Mac? If so which version?
If you compiled the library we provide, did the compilation succeed without errors?

Finally, what code is causing the problem? Can you show it here?

Thanks

Re: Does C++ API work on Android and iOS?

Posted: 24 Apr 2013, 01:22
by ganquan
i compile boost by follow this link:http://gitorious.org/boostoniphone#more, and the boost version is 1.52.0, it downloaded from boost website.

i didn't compare with the boost in API, i will try later.

i just start connect with code below:

Code: Select all

void ConnectionTest::init()
{
    gSmartFox = new Sfs2X::SmartFox(true);
	gSmartFox->ThreadSafeMode(false);
    
    gSmartFox->AddEventListener(SFSEvent::CONNECTION, new EventListenerDelegate(ConnectionTest::OnSmartFoxConnection, (void*)this));
	gSmartFox->AddEventListener(SFSEvent::CONNECTION_LOST, new EventListenerDelegate(ConnectionTest::OnSmartFoxConnectionLost, (void*)this));
	gSmartFox->AddEventListener(SFSEvent::LOGIN, new EventListenerDelegate(ConnectionTest::OnSmartFoxLogin, (void*)this));
	gSmartFox->AddEventListener(SFSEvent::LOGIN_ERROR, new EventListenerDelegate(ConnectionTest::OnSmartFoxLoginError, (void*)this));
	gSmartFox->AddEventListener(SFSEvent::LOGOUT, new EventListenerDelegate(ConnectionTest::OnSmartFoxLogout, (void*)this));
	gSmartFox->AddEventListener(BitSwarmEvent::DISCONNECT, new EventListenerDelegate(ConnectionTest::OnSmartFoxDisconnection, (void*)this));
    
    
    std::string fullPath = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename("config.xml");
    std::string * filename = new std::string(fullPath);
    
    cocos2d::CCLog("%s",fullPath.c_str());
    
	gSmartFox->LoadConfig(filename, true);
	delete filename;
	filename = NULL;
}

the init function is not crash, the crash happen after a second, the debug navigator didn't show the where it begin

Code: Select all

#0	0x00427f5e in boost::detail::thread_data_base::~thread_data_base() at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/libs/thread/src/pthread/thread.cpp:40
#1	0x001e4a27 in boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data() at /Users/ganquan/glorypingpang/trunk/glorypingpang/demo/smartfoxDemo/TestSmartFoxIOS/TestSmartFox/libs/boost/boost.framework/Headers/thread/detail/thread.hpp:52
#2	0x001e47d7 in boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data() at /Users/ganquan/glorypingpang/trunk/glorypingpang/demo/smartfoxDemo/TestSmartFoxIOS/TestSmartFox/libs/boost/boost.framework/Headers/thread/detail/thread.hpp:52
#3	0x001e47fa in boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data() at /Users/ganquan/glorypingpang/trunk/glorypingpang/demo/smartfoxDemo/TestSmartFoxIOS/TestSmartFox/libs/boost/boost.framework/Headers/thread/detail/thread.hpp:52
#4	0x001e4d58 in void boost::checked_delete<boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > > >(boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >*) at /Users/ganquan/glorypingpang/trunk/glorypingpang/demo/smartfoxDemo/TestSmartFoxIOS/TestSmartFox/libs/boost/boost.framework/Headers/checked_delete.hpp:34
#5	0x001e4e3a in boost::detail::sp_counted_impl_p<boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > > >::dispose() at /Users/ganquan/glorypingpang/trunk/glorypingpang/demo/smartfoxDemo/TestSmartFoxIOS/TestSmartFox/libs/boost/boost.framework/Headers/smart_ptr/detail/sp_counted_impl.hpp:78
#6	0x0042865e in boost::detail::sp_counted_base::release() [inlined] at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/./boost/smart_ptr/detail/sp_counted_base_pt.hpp:97
#7	0x00428634 in boost::detail::shared_count::~shared_count() [inlined] at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/./boost/smart_ptr/detail/shared_count.hpp:305
#8	0x00428634 in boost::detail::shared_count::~shared_count() [inlined] at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/./boost/smart_ptr/detail/shared_count.hpp:304
#9	0x00428634 in boost::shared_ptr<boost::detail::thread_data_base>::~shared_ptr() [inlined] at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/./boost/smart_ptr/shared_ptr.hpp:164
#10	0x00428634 in boost::lock_guard<boost::mutex>::~lock_guard() [inlined] at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/./boost/smart_ptr/shared_ptr.hpp:164
#11	0x00428628 in thread_proxy at /Users/ganquan/Desktop/Boost-Framework-For-iOS-master/boost_1_52_0/libs/thread/src/pthread/thread.cpp:172
#12	0x948c95b7 in _pthread_start ()

Re: Does C++ API work on Android and iOS?

Posted: 24 Apr 2013, 09:32
by ganquan
i rebuild boost without -stdlib=libc++ -std=gnu++11, the app don't crash now.

but, the connect fail, and i don't get the call back for it, i add AddEventListener for SFSEvent::SFS_SOCKET_ERROR, it didn't called.

i break point at TCPSocketLayer::HandleError, the SocketErrors value is 61, i don't find the number in enum SocketErrors, but 10061 is host refuse connection.

is that mean i connect to server , but server refuse my connection?

the server is on windows, and i run test on mac with iphone simulator.

i also test the Object-C API, it work fine.

Re: Does C++ API work on Android and iOS?

Posted: 24 Apr 2013, 10:20
by ganquan
ok, i get it, i only set socket address for 127.0.0.1.

it work on IOS6.1~~~

but the configure file don't work, i have to change the code in ConfigLoader::TryParse to set host ip.

Re: Does C++ API work on Android and iOS?

Posted: 24 Apr 2013, 12:16
by MBagnati
The configuration file is not supported in current release of C++ API, for this reason it does not work.
Today the API configuration is hard-coded into the ConfigLoader class, so to change configurable parameters you must change the software.
The software implementation to read the configuration file is in progress. I think that it will be delivered with the next API version.

Re: Does C++ API work on Android and iOS?

Posted: 25 Apr 2013, 09:48
by ganquan
ok, it also work on android~

Re: Does C++ API work on Android and iOS?

Posted: 26 Apr 2013, 10:49
by MBagnati
Thanks for this good news