JNIEXPORT jboolean JNICALL Java_com_jtxdriggers_android_ventriloid_VentriloInterface_recv() { _v3_net_message *msg; if ((msg = _v3_recv(V3_BLOCK))) { _v3_process_message(msg); } return msg && v3_is_loggedin(); }
void main_loop(void *connptr, MumbleClient::MumbleClientLib* mcl) { struct _conninfo *conninfo; _v3_net_message *msg; v3_event *ev; conninfo = connptr; if (debug >= 2) { v3_debuglevel(V3_DEBUG_PACKET | V3_DEBUG_PACKET_PARSE | V3_DEBUG_INFO); } if (! v3_login(conninfo->server, conninfo->username, conninfo->password, "")) { fprintf(stderr, "could not log in to ventrilo server: %s\n", _v3_error(NULL)); } while (keep_running) { // Handle the Mumble Client mcl->Pump(); // Handle incoming events msg = _v3_recv(V3_NONBLOCK); if ( msg != NULL ) { switch (_v3_process_message(msg)) { case V3_MALFORMED: _v3_debug(V3_DEBUG_INFO, "received malformed packet"); break; case V3_NOTIMPL: _v3_debug(V3_DEBUG_INFO, "packet type not implemented"); break; case V3_OK: _v3_debug(V3_DEBUG_INFO, "packet processed"); break; } // free(msg); // Looks like process_message handles freeing the memory used } // Handle any outgoing Events ev = v3_get_event(V3_NONBLOCK); if ( ev != NULL ) { if (debug) { fprintf(stderr, "vumble: got event type %d\n", ev->type); } switch (ev->type) { case V3_EVENT_DISCONNECT: keep_running = false; break; case V3_EVENT_LOGIN_COMPLETE: v3_change_channel(atoi(conninfo->channelid), ""); fprintf(stderr, "***********************************************************************************\n"); fprintf(stderr, "Connected to Ventrilo Server\n"); fprintf(stderr, "***********************************************************************************\n"); v3_serverprop_open(); break; } free(ev); } } }