NodeJS callback implementation

Hi!
I am trying to prototype a few things before using ZeroC RPC framework. Scheme is pretty straightforward. We are having some ServiceFactory, which returns Service, which is providing some functionality and invoke callback on result competition.
Server side is C++ and client side is NodeJS and Java. Java work pretty well - no question here, but I am stuck with Node JS part.
I am creating a listener in JS code and trying to pass it to service. Please see code snippet below(sorry for formatting):return ic.createObjectAdapter("").then(
function(adapter)
{
var r = adapter.addWithUUID(new CoolResultListenerI());
factory_prx.ice_getCachedConnection().setAdapter(adapter);
console.log(r);
return SRV.CoolResultListenerPrx.checkedCast(r).then(
function(listener_prx)
{
service_prx.SetListener(listener_prx);
service_prx.ApplyValue(42);
});
});
No luck here. Ice is throwing an error with valid ID but strange EP:
Ice::NoEndpointException
proxy: "8d3a083f-5814-40b9-e3f2-a928050e71f9 -t -e 1.1"
When I am trying to create an adapter with local EP(createObjectAdapterWithEndpoints):
Ice::FeatureNotSupportedException
unsupportedFeature: "object adapter endpoints not supported"
After reviewing docs/samples (where no Prx was used but Ice::Identity) can I conclude that this current approach doesn't work with ZeroC ICE ? (at least 3.6.*) version.
Thank you!
ps. Overall test is here https://github.com/gkorovkin/zeroc_js_test/
Best Answer
-
gkorovkin Member Gin KorovkinOrganization: FreelancerProject: proof of concept ✭
Sorry for borrowing you - found solution.
var prx = adapter.createProxy(r.ice_getIdentity()); service_prx.SetListener(prx); service_prx.ApplyValue(42);
But now I have an exception on server side
terminating with uncaught exception of type Ice::NoEndpointException: Reference.cpp:1676: Ice::NoEndpointException:
no suitable endpoint available for proxy `f2d96ae4-b84a-4697-8463-4b8e6c30b003 -t -e 1.1'Could you please help me on that?
0
Answers
Sorry for borrowing you - found solution.
But now I have an exception on server side
terminating with uncaught exception of type Ice::NoEndpointException: Reference.cpp:1676: Ice::NoEndpointException:
no suitable endpoint available for proxy `f2d96ae4-b84a-4697-8463-4b8e6c30b003 -t -e 1.1'
Could you please help me on that?
Hi Gin,
The problem is that you are sending a proxy to the server and that defeats the purpose of using a bidirectional connection see Bidirectional Connections page in Ice manual.
You want to instead send the Identity of the CoolResultListener object and let the server create the proxy using the connection.
Take a look at the bidirectional demos:
JS Client
C++ Server
Thanks, Jose!
Correct me if I wrong:
But there is no possibility to use this declared semantic using JavaScript bindings?
The only way that your C++ server can call to your JavaScript client is using a bidirectional connection.