Home Help Center

How to deal nicely when connections lost

sixessixes Member sixes pengOrganization: yyo game limitProject: a chinese game
One question remains on my minds for some time.
We could create a thread sending ping request
in some seconds repeatly
to detect the client whether is still online.In the meanwhile,
in the main thread there may processing the business logic.
Let's say,at some moment,the client lost its connection,
but the main thread still was in processing,then the main thread
called a response method back to the client.In this case,the main thread
would throw a connection lost exception,right?So,we have to catch
this exception in every AMD/AMI method,writing the same code dealing
with this connection lost event again and again.Here is my quesion,
could we have a more nicer solution to solve this case?Say,in AMD/AMI
methods,I donot have to deal with it.When a connection lost,it comes to
a method called processConnEvent(enum eventType,Conection*).Then we
could put all the connection releated event code in this method.
Do you understand my intendtion?
Thank you.

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You're correct, the AMI invocations will eventually fail with an Ice::ConnectionLostException exception if the connection is lost while the invocations are in progress.

    It's not exactly clear to me what you're looking for. Your code can already ignore exceptions raised by the invocations if you have another thread that checks for the server reachability with regular ice_ping calls.

    Could you post a code sample of the code you currently use and the code you would like to be able to write?

    Cheers,
    Benoit.
Sign In or Register to comment.