Skip to content

Commit

Permalink
Add sample for cancelling timer
Browse files Browse the repository at this point in the history
  • Loading branch information
nanangizz committed Jan 28, 2025
1 parent 542d054 commit 3eb05f8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pjsip-apps/src/swig/java/sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,15 @@ private static void runWorker() {
try {
app.init(observer, ".", true);

// Schedule a timer
long token = app.ep.utilTimerSchedule(1000, -100);
// Immediately cancel it, callback should not be invoked
app.ep.utilTimerCancel(token);

// Schedule another timer
app.ep.utilLogWrite(3, "-TIMER-", "Scheduling timer: timeout=1000ms, user data=-99");
app.ep.utilTimerSchedule(1000, -99);

} catch (Exception e) {
System.out.println(e);
app.deinit();
Expand Down

0 comments on commit 3eb05f8

Please sign in to comment.