Multiple control point callback functions not possible?
Robert Johansson <[email protected]> Tue, 6 Apr 2004 13:39:43 +0200
| Newsgroups | gmane.linux.upnp-sdk.general |
|---|---|
| Message-ID | <5BB336130A66D7119DEF009027463C2C8CBE39@BERNTSSON> |
Hello!
I wonder if I have missed something out, or if there is a bug in libupnp,
because I fail to register multiple control point callbacks using
UpnpRegisterCallback. In the "UPnP by Design design" book, for you who have
it, the text on top of page 415 insinuates that having multiple client
handles should be possible.
The following code demonstrates the problem.
Registering the first callback is ok, but trying to register additional
callbacks results in getting error code -120 "Unknown error".
I would appreciate if anyone could point out if I've made some mistake.
/Robert Johansson
- - - cut here - - -
#include <iostream>
#include "upnp.h"
#include "upnptools.h"
using namespace std;
UpnpClient_Handle handleOne;
UpnpClient_Handle handleTwo;
int callbackOne (Upnp_EventType eventType, void* event, void* cookie) {
return UPNP_E_SUCCESS;
}
int callbackTwo (Upnp_EventType eventType, void* event, void* cookie) {
return UPNP_E_SUCCESS;
}
void errorWrapper(int error) {
if (error != UPNP_E_SUCCESS) {
cout << "Error code " << error << ": " << UpnpGetErrorMessage(error) <<
endl;
} else {
cout << "OK" << endl;
}
}
int main() {
UpnpInit(NULL, 0);
cout << "Registering first callback... ";
errorWrapper(UpnpRegisterClient (callbackOne, NULL, &handleOne));
cout << "Registering second callback... ";
errorWrapper(UpnpRegisterClient (callbackTwo, NULL, &handleTwo));
cout << "Unregistering first callback... ";
errorWrapper(UpnpUnRegisterClient(handleOne));
cout << "Unregistering second callback... ";
errorWrapper(UpnpUnRegisterClient(handleTwo));
UpnpFinish();
return 0;
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click