Classes versus Interfaces used for callbacks

in Help Center
Hi!
Regarding the callback demo, I have noticed that its Slice code declares two classes, but no interfaces. Checking with the documentation again, it seems that one of the reasons is is that interfaces "allow behaviour to be implemented only on the server side". This makes sense to me, but I wonder: Could the class which in this example is implemented on the server anyways, have been replaced by an interface, and retain a class declaration only for the callback object to be implemented on the client? Something like this:
Thanks,
Catalin
Regarding the callback demo, I have noticed that its Slice code declares two classes, but no interfaces. Checking with the documentation again, it seems that one of the reasons is is that interfaces "allow behaviour to be implemented only on the server side". This makes sense to me, but I wonder: Could the class which in this example is implemented on the server anyways, have been replaced by an interface, and retain a class declaration only for the callback object to be implemented on the client? Something like this:
// original class CallbackReceiver { void callback(); }; [COLOR=blue]class[/COLOR] Callback { void initiateCallback(CallbackReceiver* proxy); void shutdown(); };
// alternative class CallbackReceiver { void callback(); }; [COLOR=blue]interface[/COLOR] Callback { void initiateCallback(CallbackReceiver* proxy); void shutdown(); };
Thanks,
Catalin
0
Comments
I am thinking of one more thing:
In the current example (with classes), I have commented out the following line from the server code:
Still everything works just as well as when the line is compiled. What is this line's role? As far as I can see, the self variable is not used anywhere in the remainder of the server code.
I am sure that you guys have a lot of things to do, but if this demo is a piece of cake for you, could someone please post some code here which implements callbacks with interfaces.
Thanks,
Catalin
As for changing from classes to interfaces, nothing special is needed other than simply changing "class" to "interface" in Callback.ice.