vrpn_Tracker_ButtonFly::~vrpn_Tracker_ButtonFly (void) { int i; // Tear down the button axes (which will include the // button callbacks and remotes). for (i = 0; i < d_num_axes; i++) { teardown_channel(&d_axes[i]); } // Tear down the analog update callbacks and remotes (if they exist) if (d_vel_scale != NULL) { d_vel_scale->unregister_change_handler(this, handle_velocity_update); try { delete d_vel_scale; } catch (...) { fprintf(stderr, "vrpn_Tracker_ButtonFly::~vrpn_Tracker_ButtonFly(): delete failed\n"); return; } } if (d_rot_scale != NULL) { d_rot_scale->unregister_change_handler(this, handle_rotation_update); try { delete d_rot_scale; } catch (...) { fprintf(stderr, "vrpn_Tracker_ButtonFly::~vrpn_Tracker_ButtonFly(): delete failed\n"); return; } } }
vrpn_Tracker_AnalogFly::~vrpn_Tracker_AnalogFly (void) { // Tear down the analog update callbacks and remotes teardown_channel(&d_x); teardown_channel(&d_y); teardown_channel(&d_z); teardown_channel(&d_sx); teardown_channel(&d_sy); teardown_channel(&d_sz); // Tear down the reset button update callback and remote (if there is one) if (d_reset_button != NULL) { d_reset_button->unregister_change_handler(this, handle_reset_press); try { delete d_reset_button; } catch (...) { fprintf(stderr, "vrpn_Tracker_AnalogFly::~vrpn_Tracker_AnalogFly(): delete failed\n"); return; } } // Tear down the clutch button update callback and remote (if there is one) if (d_clutch_button != NULL) { d_clutch_button->unregister_change_handler(this, handle_clutch_press); try { delete d_clutch_button; } catch (...) { fprintf(stderr, "vrpn_Tracker_AnalogFly::~vrpn_Tracker_AnalogFly(): delete failed\n"); return; } } }
inline static void teardown_relays(void) { debug("relays: teardown"); struct RelayListener *cur = context.relays; for(int c = 0; c < context.relays_count; ++ c) { switch(cur->proto) { case IPPROTO_TCP: { evconnlistener_free(cur->tcp_listener); cur->tcp_listener = NULL; } break; case IPPROTO_UDP: { event_free(cur->udp_listener); cur->udp_listener = NULL; } break; default: debug("%d protocol not yet implemented", cur->proto); break; } cur->proto = 0; ++ cur; } while(context.channels) teardown_channel(context.channels, 1); free(context.relays); }
vrpn_Tracker_AnalogFly::~vrpn_Tracker_AnalogFly (void) { // Tear down the analog update callbacks and remotes teardown_channel(&d_x); teardown_channel(&d_y); teardown_channel(&d_z); teardown_channel(&d_sx); teardown_channel(&d_sy); teardown_channel(&d_sz); // Tear down the reset button update callback and remote (if there is one) if (d_reset_button != NULL) { d_reset_button->unregister_change_handler(this, handle_reset_press); delete d_reset_button; } // Tear down the clutch button update callback and remote (if there is one) if (d_clutch_button != NULL) { d_clutch_button->unregister_change_handler(this, handle_clutch_press); delete d_clutch_button; } }
inline static void process_control_message(struct bufferevent *bev, struct Message *msg) { debug("control: processing message"); switch(msg->type) { case NOOP: debug("control: message NOOP"); break; case ALIVE: { struct MessageAlive *ali = (struct MessageAlive *) msg; debug("control: message ALIVE(%d)", ali->seq); if(context.msg_alive.seq != ali->seq) { context.msg_alive.seq = ali->seq; bufferevent_write( bev, &context.msg_alive, sizeof(context.msg_alive)); } else { struct timespec cur; clock_gettime(CLOCK_MONOTONIC, &cur); context.ping = ( context.ping - context.last_alive + cur.tv_sec * 1000LL + (cur.tv_nsec + 999999LL) / 1000000LL ) / 4; debug("control: estimated ping %ums", context.ping); } } break; case CLOSE_CHANNEL: { struct MessageCloseChannel *clo = (struct MessageCloseChannel *) msg; debug("control: message CLOSE_CHANNEL"); union Channel *channel = find_channel(&clo->response); if(!channel) debug("control: channel doesn't exist"); else teardown_channel(channel, 0); } break; case CHALLENGE: case RESPONSE: { debug( "control: not yet implemented message (%s)", message_get_type_string(msg)); } break; case OPEN_CHANNEL: default: { debug( "control: invalid message (%s)", message_get_type_string(msg)); } break; } }