Home Help Center

Is there AMI style ice_getConnection?

rolandsunrolandsun beijingMember roland sunOrganization: metstarProject: weather radar product generation software
I try to combine Bidirectional Connections and AMI in my project , I use the QtDispatcher atrributted by alex, and I try to avoid deadlock by using begin_xx end_xx AMI call ,and uncheckCast.. , everything works well except the ice_getConnection is called during
 adapter->activate();
    proxy->ice_getConnection()->setAdapter(adapter);
    proxy->addClient(ident);

it seems to hang,and I can not find the begin_ice_getConnect() in ICE's api,how can I fix or avoid it?

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Roland,

    As you suspected, calling ice_getConnection behaves similarly to making a synchronous proxy invocation, in that calling it from the Qt dispatch thread will cause the program to hang.

    The proxy also provides the method ice_getCachedConnection, but this method returns null if no connection has been established yet.

    To avoid blocking, I recommend calling begin_ice_ping. Upon successful completion, the connection will be established and you can do something like this in the completion callback:
    Ice::ConnectionPtr conn = proxy->ice_getCachedConnection();
    assert(conn);
    conn->setAdapter(...);
    
    We'll consider adding a better solution to a future Ice release.

    Regards,
    Mark
  • rolandsunrolandsun beijingMember roland sunOrganization: metstarProject: weather radar product generation software
    Thanks Mark, I think it's the best solution we can figure out right now.
Sign In or Register to comment.