/* * rend_callback * * This gets called from the main thread when there is a * message waiting to be processed. */ void rend_callback(void) { REND_MESSAGE msg; sw_discovery_oid rend_oid; sw_result result; /* here, we've seen the message, now we have to process it */ if(rend_read_message(&msg) != sizeof(msg)) { DPRINTF(E_FATAL,L_REND,"Rendezvous socket closed (daap server crashed?) Aborting.\n"); exit(EXIT_FAILURE); } switch(msg.cmd) { case REND_MSG_TYPE_REGISTER: DPRINTF(E_DBG,L_REND,"Registering %s.%s (%d)\n",msg.type,msg.name,msg.port); if((result=sw_discovery_publish(rend_handle, 0, /* interface handle */ msg.name, msg.type, NULL, /* domain */ NULL, /* host */ msg.port, "\011txtvers=1\034Database ID=beddab1edeadbea7", /* text record */ 39, /* text record length */ rend_howl_reply, NULL, &rend_oid)) != SW_OKAY) { DPRINTF(E_WARN,L_REND,"Error registering name\n"); rend_send_response(-1); } else { rend_send_response(0); /* success */ } break; case REND_MSG_TYPE_UNREGISTER: DPRINTF(E_WARN,L_REND,"Unsupported function: UNREGISTER\n"); rend_send_response(-1); /* error */ break; case REND_MSG_TYPE_STOP: DPRINTF(E_DBG,L_REND,"Stopping mDNS\n"); rend_send_response(0); //sw_rendezvous_stop_publish(rend_handle); sw_discovery_fina(rend_handle); break; case REND_MSG_TYPE_STATUS: DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 0\n"); rend_send_response(0); /* success */ break; default: break; } }
HowlSession::~HowlSession() { if (mSession) sw_discovery_fina(mSession); }