Hello,
I have discovered that when the Internet connection on the Android device is switched off, the game crashes on performing a:
mSmartFox->Connect(IP_PRODUCTION_SERVER, 9933);
I have tried the FullHouse C++ example in the iOS simulator disconnecting the Internet cable and the game crashes too.
Is there any way to avoid this using SmartFox API ? or is needed to check Internet connection before trying to do the connection ?
Thank you
Antonio.
Game crash when trying to connect without Internet
Moderators: Lapo, Bax, MBagnati
-
- Posts: 7
- Joined: 06 Nov 2013, 11:31
Re: Game crash when trying to connect without Internet
Thanks for reporting. By crash you mean the app quits or something else?
Can you give us a transcript of the errors you are getting?
Thanks
Can you give us a transcript of the errors you are getting?
Thanks
-
- Posts: 7
- Joined: 06 Nov 2013, 11:31
Re: Game crash when trying to connect without Internet
By crash I mean that game freezes in Simulator for a while and after it quits. The Xcode console shows the following message:
Assertion failed: (px != 0), function operator->, file /Users/antonio/Desktop/SFS2X_Cpp_Examples/FullHouse (XCode, VS2010, Eclipse)/client/FullHouse/FullHouse/libs/boost.framework/Headers/smart_ptr/shared_ptr.hpp, line 424.
The steps I do are:
1- Disconnect the Ethernet cable to ensure there is no Internet
2- Run the example
3- I click on play first time and nothing happens, but when I try another time I get the assertion.
Hope it helps to you and thank you,
Antonio
Assertion failed: (px != 0), function operator->, file /Users/antonio/Desktop/SFS2X_Cpp_Examples/FullHouse (XCode, VS2010, Eclipse)/client/FullHouse/FullHouse/libs/boost.framework/Headers/smart_ptr/shared_ptr.hpp, line 424.
The steps I do are:
1- Disconnect the Ethernet cable to ensure there is no Internet
2- Run the example
3- I click on play first time and nothing happens, but when I try another time I get the assertion.
Hope it helps to you and thank you,
Antonio
Re: Game crash when trying to connect without Internet
The client API has been designed to be a one shot API.
This means that API must be re-initialized after each usage.
With usage word, I mean a connection session with SmartFoxServer completed successfully or with error.
So, the application must:
1) Create an API instance
For instance: mySmartFoxInstance = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox(true));
2) Register the listeners for API events.
For instance: mySmartFoxInstance->AddEventListener(SFSEvent::CONNECTION, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(MyClass::OnSmartFoxConnection, (unsigned long long)this)));
3) Try to establish the connection with SmartFoxServer.
For instance: mySmartFoxInstance->Connect(IP_PRODUCTION_SERVER, 9933)
4) Check the connection result (For instance into the listening method MyClass::OnSmartFoxConnection)
On error, to retry a failed connection, repeat all from step [1]
The FullHouse sample has a bug.
When it is not able to establish the connection with SmartFoxServer, it shows Connect Again...but it forgets to re-initialize the client API
To fix FullHouse behaviour, must be added this statement
as last row in the function
In your application, when the Internet connection on the Android device is switched off, you should receive a failure result into the function registered as listener for SFSEvent::CONNECTION event.
As ditto above, before try again to establish the network connection with SmartFoxServer, you must re-initialize the client API (in other words re-create an API instance and register again all event listeners).
This means that API must be re-initialized after each usage.
With usage word, I mean a connection session with SmartFoxServer completed successfully or with error.
So, the application must:
1) Create an API instance
For instance: mySmartFoxInstance = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox(true));
2) Register the listeners for API events.
For instance: mySmartFoxInstance->AddEventListener(SFSEvent::CONNECTION, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(MyClass::OnSmartFoxConnection, (unsigned long long)this)));
3) Try to establish the connection with SmartFoxServer.
For instance: mySmartFoxInstance->Connect(IP_PRODUCTION_SERVER, 9933)
4) Check the connection result (For instance into the listening method MyClass::OnSmartFoxConnection)
On error, to retry a failed connection, repeat all from step [1]
The FullHouse sample has a bug.
When it is not able to establish the connection with SmartFoxServer, it shows Connect Again...but it forgets to re-initialize the client API
To fix FullHouse behaviour, must be added this statement
Code: Select all
FullHouseServer::getSingleton().initServer();
as last row in the function
Code: Select all
void LayerDialog::showConnect( )
Code: Select all
void LayerDialog::showConnect( )
{
mEditIP->setPosition(mIPNode->getPosition());
mEditPort->setPosition(mPortNode->getPosition());
mPokeNode->setVisible(false);
mEditIP->setVisible(true);
mEditPort->setVisible(true);
mConnectBtn->setVisible(true);
mEditIP->setText("192.168.5.101");
mEditPort->setText("9933");
setTipText("Connect Again");
FullHouseServer::getSingleton().initServer();
}
In your application, when the Internet connection on the Android device is switched off, you should receive a failure result into the function registered as listener for SFSEvent::CONNECTION event.
As ditto above, before try again to establish the network connection with SmartFoxServer, you must re-initialize the client API (in other words re-create an API instance and register again all event listeners).
Who is online
Users browsing this forum: No registered users and 19 guests