duhber / rcf-cpp

Automatically exported from code.google.com/p/rcf-cpp
0 stars 0 forks source link

How can server socket know connection or disconnection of clients when using the RCF? #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
How can server socket know the connection or disconnection of clients when 
I use RCF to write a chatroom program?

Thanks

Original issue reported on code.google.com by adylee1...@gmail.com on 16 Jul 2009 at 1:10

GoogleCodeExporter commented 9 years ago
From within a remote call, you can execute the following code:

               // ...
               RCF::RcfSession& session = RCF::getCurrentRcfSession();
               session.setOnDestroyCallback( boost::bind(onDisconnect) );
               // ...

, where onDisconnect is a function looking like this:

void onDisconnect()
{
       // ...
}

Using boost::bind, you can pass extra arguments into the callback as well.

As for detecting a client connecting, you can have your clients call a 
particular 
function on the server, to notify the server that they have connected.

Original comment by jarl.lin...@gmail.com on 17 Jul 2009 at 4:43

GoogleCodeExporter commented 9 years ago
Thank you very much!

Original comment by adylee1...@gmail.com on 20 Jul 2009 at 12:37

GoogleCodeExporter commented 9 years ago

Original comment by jarl.lin...@gmail.com on 30 Jul 2009 at 9:18