Results 1 to 3 of 3

Thread: A question about callback

  1. #1
    skyriver is offline Registered User
    Join Date
    Jun 2005
    Posts
    9

    A question about callback

    Hi!
    I have two programs. One is ICE server,the other is ICE client. After ICE client is runned, the ICE client register a callback object to ICE server program
    .I save the callback object in ICE server.

    OK,Ice server program can call the object to do something. For example, by the object Ice server program can call a function of Ice client program.
    After a while, Ice client program was closed. At that time , ICE server program called the callback object to call a method of Ice client program, a ICE exception was throwed.

    My question : How can i Know the client programe was close and not to call the callback object , or how can i catch the exception in my porgram.

    Thanks a lot !

  2. #2
    skyriver is offline Registered User
    Join Date
    Jun 2005
    Posts
    9
    my ice file part:
    //////////////////////////////////////////
    class ServerCallBack
    {
    void Connected(int iIP1,int iIP2,int iIP3,int iIP4,string sPCName,string sComputorID);
    void Disconnect(int iIP1,int iIP2,int iIP3,int iIP4,string sPCName,string sComputorID);
    int ReportEvent(AgentEventData poEvent);

    };
    ///////////////////////////////////////////

    server ICE function:
    //////////////////////////////
    RegisterCallbackObj(const ::ServerCallBackPrx& proxy, const ::std::string& sComputorID, const ::Ice::Current& c)
    //////////////////////////////

  3. #3
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Quote Originally Posted by skyriver
    Hi!
    I have two programs. One is ICE server,the other is ICE client. After ICE client is runned, the ICE client register a callback object to ICE server program
    .I save the callback object in ICE server.

    OK,Ice server program can call the object to do something. For example, by the object Ice server program can call a function of Ice client program.
    After a while, Ice client program was closed. At that time , ICE server program called the callback object to call a method of Ice client program, a ICE exception was throwed.

    My question : How can i Know the client programe was close and not to call the callback object , or how can i catch the exception in my porgram.
    When you invoke an operation on an object whose server has shut down, you will typically get a ConnectionRefusedException or ConnectionLostException. You cannot know in advance whether or not a particular invocation will succed or not, depending on whether the receiving process has exited. Instead, you have to catch the exception and handle it. Something like:

    Code:
    try {
        someProxy->someOperation(params);
    }
    catch(const Ice::SocketException& ex)
    {
        // invocation failed, deal with that somehow
    }
    Of course, you can catch exceptions more specifically, such as catching Ice::ConnectionRefused exception only, and you need not wrap every operation invocation in a try-catch block. Instead, it is often easier to let the exception propagate up the stack and handle it at a higher level of abstraction.

    This is really beyond the scope of Ice and relates more to exception handling in general. In summary, you cannot know whether a particular invocation will succeed or not before actually making the invocation--the only way to find out about the status of the invocation is to see whether it raises an exception.

    Cheers,

    Michi.
    Last edited by marc; 06-21-2005 at 07:04 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ? about callback : NoEndpointException
    By Jacky_Lee in forum Help Center
    Replies: 10
    Last Post: 08-28-2006, 09:20 PM
  2. a callback function question
    By laotee in forum Help Center
    Replies: 1
    Last Post: 09-26-2005, 02:03 AM
  3. Replies: 1
    Last Post: 07-30-2005, 07:12 AM
  4. The "callback" string in the callback demo
    By catalin in forum Help Center
    Replies: 2
    Last Post: 08-27-2004, 12:53 AM
  5. Callback and Glacier Example?
    By feline in forum Help Center
    Replies: 5
    Last Post: 03-22-2004, 04:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •