private void HandlePendingAlertCallback(Core.Alert a) { log.Trace("libtorrent event {0}: {1}", a.what(), a.message()); if (!alertType.ContainsKey(a.GetType())) { return; } switch (alertType[a.GetType()]) { case 0: TorrentAddedAlert((Core.torrent_added_alert)a); break; case 1: OnTorrentUpdateAlert((Core.state_update_alert)a); break; case 2: // torrent_paused_alert break; case 3: // torrent_resumed_alert break; case 4: // torrent_removed_alert break; case 5: // torrent_deleted_alert break; case 6: // torrent_error_alert break; case 7: // dht_stats_alert break; case 8: // dht_bootstrap_alert break; case 9: OnSaveResumeDataAlert((Core.save_resume_data_alert)a); break; case 10: OnSaveResumeDataFailedAlert((Core.save_resume_data_failed_alert)a); break; case 11: // piece_finished_alert break; default: break; } }
private static void HandleAlertCallback(Core.Alert a) { using (a) { Action <object> run; if (Alert2Func.TryGetValue(a.GetType(), out run)) { run(a); } } }
private static void HandleAlertCallback(IntPtr alertHandle) { try { Alert_What_Get(alertHandle, alertNameFromHandle, alertNameFromHandle.Capacity); Type type = Type.GetType("Tsunami.Core." + alertNameFromHandle.ToString(), true); using (Alert alertTypeClass = (Alert)Activator.CreateInstance(type, alertHandle)) { Action <Object> run; if (Alert2Func.TryGetValue(alertTypeClass.GetType(), out run)) { run(alertTypeClass); } } } catch (TypeLoadException) { Alert_Destroy(alertHandle); } }