OnCallbackConnectionCreated destroys server session

RCF support and general discussion.
Post Reply
BigWCharly
Posts: 6
Joined: Sat Aug 30, 2014 8:19 am

OnCallbackConnectionCreated destroys server session

Post by BigWCharly »

I'm trying to extend the "Identifying Clients" in the callback example http://www.deltavsoft.com/doc/rcf_user_ ... ng_clients

My goal is to remove the RcfClient from the map when the client disconnects.

So I tried adding

Code: Select all

sessionPtr->setOnDestroyCallback (std::bind (_OnCallbackConnectionDestroyed, args::_1));
The following happens and goes wrong at step 4:
1. A callback connection is initiated by the client
2. onCallbackConnectionCreated is called
3. The method _OnCallbackConnectionDestroyed is set as callback for when the session is destroyed
4. !!! => Immediately afterwards _OnCallbackConnectionDestroyed is called <= !!!
5. The client does receive callbacks!
6. The client process is closed
7. The server crashes with the following message:

terminate called after throwing an instance of 'RCF::Exception'
what(): [98: DNS lookup of network address failed, for name "%1". OS: 0 - Success][1: Operating system][0: Success][What: ][Context: ./src/RCF/TcpClientTransport.cpp:118]
Aborted

What's the solution to this problem?
Thanks again for your help.

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: OnCallbackConnectionCreated destroys server session

Post by jarl »

Because the callback connection is used to actively make calls back to the client, it doesn't have a RcfSession of its own. The RcfSession you receive as a parameter in onCallbackConnectionCreated() is only intended to provide you with any session-specific information that the client may have set up, before calling createCallbackConnection().

You'll need to have two connections between the client and the server - one for client-to-server calls, and one for server-to-client calls. The client-to-server connection is the one that you should use for detecting disconnection (using RcfSession::setOnDestroyCallback()). When you detect a disconnection, you can then remove the corresponding server-to-client connection from the map of server-to-client connections.

Hope that helps.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Post Reply