Archived
This forum has been archived. Please start a new discussion on GitHub.
C++ AMI with Type-Safe Callback - using a proxy inside the return callback
Hi,
I have some problem using C++ AMI with type-safe methods (Ice 3.4.2 - Windows 8)
I have a service to send 500.000 referentiel datas. Too big for one request, so I use a getFromIndex query to send back to client a 1000 data block. So the client repeat the getFromIndex call until it returns a 0 size block, else increment the from index with the data block size.
In the type safe callback, since I have no access to the proxy used for the begin_...., I have add it to my callback class (and a pointer to my GUI), but when I use it, I got an exception near :
I have done the same kind of thing with the non type-safe callback, and it's fine
(using the proxy returned by getProxy())
Does anybody see what am I doing wrong ?
Thanks for your help.
Here my code:
This is how I initiate it :
I have some problem using C++ AMI with type-safe methods (Ice 3.4.2 - Windows 8)
I have a service to send 500.000 referentiel datas. Too big for one request, so I use a getFromIndex query to send back to client a 1000 data block. So the client repeat the getFromIndex call until it returns a 0 size block, else increment the from index with the data block size.
In the type safe callback, since I have no access to the proxy used for the begin_...., I have add it to my callback class (and a pointer to my GUI), but when I use it, I got an exception near :
::Ice::AsyncResultPtr IceProxy::Shield::InstrumentQuery::begin_getInstruments(::Ice::Int fromIndex, const ::Ice::Context* __ctx, const ::IceInternal::CallbackBasePtr& __del, const ::Ice::LocalObjectPtr& __cookie) { [B]__checkAsyncTwowayOnly[/B](__Shield__InstrumentQuery__getInstruments_name);
I have done the same kind of thing with the non type-safe callback, and it's fine
(using the proxy returned by getProxy())
Does anybody see what am I doing wrong ?
Thanks for your help.
Here my code:
// ------------------------------ Run Async Callback Type-Safe --------------------------- class GetInstrumentCBTypeSafe : public IceUtil::Shared { FLTKPrinterClient* win; Shield::InstrumentQueryPrx& instrumentQuery; public: GetInstrumentCBTypeSafe(FLTKPrinterClient* w, Shield::InstrumentQueryPrx& proxy) : win(w), instrumentQuery(proxy) {} void getInstrumentCB(const Shield::Instruments& results) { IceUtil::Mutex::Lock lock(mutex); if (results.size() != 0) { InsertResultToInstruments(results, instruments); Shield::Callback_InstrumentQuery_getInstrumentsPtr getInstrumentCB = newCallback_InstrumentQuery_getInstruments(this, &GetInstrumentCBTypeSafe::getInstrumentCB, &GetInstrumentCBTypeSafe::failureCB); [B]instrumentQuery[/B]->begin_getInstruments(currentPosition, getInstrumentCB); currentPosition += results.size(); } else isFinished = true; GUIRefres(); } void failureCB(const Ice::Exception& ex) { /* TODO */ } }; typedef IceUtil::Handle<GetInstrumentCBTypeSafe> GetInstrumentCBTypeSafePtr;
This is how I initiate it :
Shield::InstrumentQueryPrx instrumentQuery = GetInstrumentPrx(); IceUtil::Mutex::Lock lock(mutex); GetInstrumentCBTypeSafePtr cb = new GetInstrumentCBTypeSafe(win, instrumentQuery); Shield::Callback_InstrumentQuery_getInstrumentsPtr getInstrumentCB = newCallback_InstrumentQuery_getInstruments(cb, &GetInstrumentCBTypeSafe::getInstrumentCB, &GetInstrumentCBTypeSafe::failureCB); // Starting <numRequests> calls in parallel for (int i = 0; i < numRequests; ++i, currentPosition += 1000) instrumentQuery->begin_getInstruments(currentPosition, getInstrumentCB);
0
Comments
-
Ok I found my mistake, I have used a reference to the proxy instead of a copy in the callback.
It works fine now.class GetInstrumentCBTypeSafe : public IceUtil::Shared { FLTKPrinterClient* win; [B]Shield::InstrumentQueryPrx instrumentQuery;[/B] public: GetInstrumentCBTypeSafe(FLTKPrinterClient* w, Shield::InstrumentQueryPrx proxy)
0