Hi Bax and Lapo
I use KillConnection function of Smartfox class to test the reconnection system. The event USER_RECONNECTION_TRY has been fired in server side, but in client side there is no event such as SFSEvent::CONNECTION_RETRY or SFSEvent::CONNECTION_RESUME has fired. I don't know how to fix it and wonder "Does C++ API support reconnection in 1.1.2 version?". Hope you will help me to fix this problem.
Thanks
Can not retry connection in C++ API
Moderators: Lapo, Bax, MBagnati
-
- Posts: 4
- Joined: 24 Jul 2014, 03:52
Re: Can not retry connection in C++ API
Hi,
they are implemented.
Can you just tell me what is the setting for the "User reconnection time" in your Zone?
Also how do you test the disconnection?
thanks
they are implemented.
Can you just tell me what is the setting for the "User reconnection time" in your Zone?
Also how do you test the disconnection?
thanks
-
- Posts: 4
- Joined: 24 Jul 2014, 03:52
Re: Can not retry connection in C++ API
Hi
The "User reconnection time" that I use in server config is 30 seconds.
In Client, I add 2 events: SFSEvent::CONNECTION_RETRY and SFSEvent::CONNECTION_RESUME
void CasinoServer::initServer()
{
// Initialize Smart Fox
mSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox(true));
mSmartFox->ThreadSafeMode(true);
// Add event listeners
mSmartFox->AddEventListener(SFSEvent::CONNECTION_RETRY, boost::shared_ptr<EventListenerDelegate>(new EventListenerDelegate(CasinoServer::OnSmartFoxConnectionRetry, (unsigned long long)this)));
mSmartFox->AddEventListener(SFSEvent::CONNECTION_RESUME, boost::shared_ptr<EventListenerDelegate>(new EventListenerDelegate(CasinoServer::OnSmartFoxConnectionResume, (unsigned long long)this)));
}
void CasinoServer::OnSmartFoxConnectionRetry(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
CCLog("Retry");
}
void CasinoServer::OnSmartFoxConnectionResume(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
CCLog("Resume");
}
And then I use KillConnection function to test: mSmartFox->KillConnection();
But I do not see any thing such as Retry or Resume in console
In server, I add 2 events as client in my extension
public void init(){
this.addEventHandler(SFSEventType.USER_RECONNECTION_TRY, OnUserReconnectionTry.class);
this.addEventHandler(SFSEventType.USER_RECONNECTION_SUCCESS, OnUserReconnectionSuccess.class);
}
public class OnUserReconnectionTry extends BaseServerEventHandler {
public void handleServerEvent(ISFSEvent event) throws SFSException {
//Log Retry connection
}
}
public class OnUserReconnectionSuccess extends BaseServerEventHandler {
public void handleServerEvent(ISFSEvent event) throws SFSException {
//Log Reconnection success
}
}
When I kill connection, I only see "Retry connection log" in server, but "Reconnection success log" is not
I dont know I have missed something when I implement
Thanks
The "User reconnection time" that I use in server config is 30 seconds.
In Client, I add 2 events: SFSEvent::CONNECTION_RETRY and SFSEvent::CONNECTION_RESUME
void CasinoServer::initServer()
{
// Initialize Smart Fox
mSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox(true));
mSmartFox->ThreadSafeMode(true);
// Add event listeners
mSmartFox->AddEventListener(SFSEvent::CONNECTION_RETRY, boost::shared_ptr<EventListenerDelegate>(new EventListenerDelegate(CasinoServer::OnSmartFoxConnectionRetry, (unsigned long long)this)));
mSmartFox->AddEventListener(SFSEvent::CONNECTION_RESUME, boost::shared_ptr<EventListenerDelegate>(new EventListenerDelegate(CasinoServer::OnSmartFoxConnectionResume, (unsigned long long)this)));
}
void CasinoServer::OnSmartFoxConnectionRetry(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
CCLog("Retry");
}
void CasinoServer::OnSmartFoxConnectionResume(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
CCLog("Resume");
}
And then I use KillConnection function to test: mSmartFox->KillConnection();
But I do not see any thing such as Retry or Resume in console
In server, I add 2 events as client in my extension
public void init(){
this.addEventHandler(SFSEventType.USER_RECONNECTION_TRY, OnUserReconnectionTry.class);
this.addEventHandler(SFSEventType.USER_RECONNECTION_SUCCESS, OnUserReconnectionSuccess.class);
}
public class OnUserReconnectionTry extends BaseServerEventHandler {
public void handleServerEvent(ISFSEvent event) throws SFSException {
//Log Retry connection
}
}
public class OnUserReconnectionSuccess extends BaseServerEventHandler {
public void handleServerEvent(ISFSEvent event) throws SFSException {
//Log Reconnection success
}
}
When I kill connection, I only see "Retry connection log" in server, but "Reconnection success log" is not
I dont know I have missed something when I implement
Thanks
Re: Can not retry connection in C++ API
Thanks. We'll investigate and get back to you.
-
- Posts: 4
- Joined: 24 Jul 2014, 03:52
Re: Can not retry connection in C++ API
Hi Lapo, I found strange thing in SmartFox.cpp
// -------------------------------------------------------------------
// OnSocketClose
// -------------------------------------------------------------------
void SmartFox::OnSocketClose(unsigned long long context, boost::shared_ptr<BaseEvent> e)
{
SmartFox* instance = (SmartFox*)context;
boost::shared_ptr<BitSwarmEvent> evt = (boost::static_pointer_cast<BitSwarmEvent>)(e);
instance->Reset();
// Fire event
boost::shared_ptr<map<string, boost::shared_ptr<void> > > data (new map<string, boost::shared_ptr<void> >());
data->insert(pair<string, boost::shared_ptr<void> >("reason", (*(evt->Params()))["reason"]));
boost::shared_ptr<BaseEvent> sfsEvt (new SFSEvent(SFSEvent::CONNECTION_LOST, data));
instance->DispatchEvent(sfsEvt);
}
// -------------------------------------------------------------------
// OnSocketReconnectionTry
// -------------------------------------------------------------------
void SmartFox::OnSocketReconnectionTry(unsigned long long context, boost::shared_ptr<BaseEvent> e)
{
SmartFox* instance = (SmartFox*)context;
// Fire event
boost::shared_ptr<BaseEvent> sfsEvt (new SFSEvent(SFSEvent::CONNECTION_RETRY));
}
At OnSocketReconnectionTry function. It have not this line: instance->DispatchEvent(sfsEvt);
// -------------------------------------------------------------------
// OnSocketClose
// -------------------------------------------------------------------
void SmartFox::OnSocketClose(unsigned long long context, boost::shared_ptr<BaseEvent> e)
{
SmartFox* instance = (SmartFox*)context;
boost::shared_ptr<BitSwarmEvent> evt = (boost::static_pointer_cast<BitSwarmEvent>)(e);
instance->Reset();
// Fire event
boost::shared_ptr<map<string, boost::shared_ptr<void> > > data (new map<string, boost::shared_ptr<void> >());
data->insert(pair<string, boost::shared_ptr<void> >("reason", (*(evt->Params()))["reason"]));
boost::shared_ptr<BaseEvent> sfsEvt (new SFSEvent(SFSEvent::CONNECTION_LOST, data));
instance->DispatchEvent(sfsEvt);
}
// -------------------------------------------------------------------
// OnSocketReconnectionTry
// -------------------------------------------------------------------
void SmartFox::OnSocketReconnectionTry(unsigned long long context, boost::shared_ptr<BaseEvent> e)
{
SmartFox* instance = (SmartFox*)context;
// Fire event
boost::shared_ptr<BaseEvent> sfsEvt (new SFSEvent(SFSEvent::CONNECTION_RETRY));
}
At OnSocketReconnectionTry function. It have not this line: instance->DispatchEvent(sfsEvt);
Re: Can not retry connection in C++ API
Hi,
You are right, function OnSocketReconnectionTry does not fire up the CONNECTION_RETRY event because the DispatchEvent statement is missing.
But I think that this is not the only reason that causes the error. I suspects that the error cause is little more extended.
I am working to fix the problem.
I am apologize for the error, I think to give you a fix in a little time
You are right, function OnSocketReconnectionTry does not fire up the CONNECTION_RETRY event because the DispatchEvent statement is missing.
But I think that this is not the only reason that causes the error. I suspects that the error cause is little more extended.
I am working to fix the problem.
I am apologize for the error, I think to give you a fix in a little time
Who is online
Users browsing this forum: No registered users and 44 guests