Skip to content

Commit ab61f84

Browse files
committed
refactor: convenience functions
1 parent 1a5175c commit ab61f84

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/main/kotlin/spp/protocol/service/listen/ListenExtensions.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import io.vertx.core.Future
2020
import io.vertx.core.Promise
2121
import io.vertx.core.Vertx
2222
import spp.protocol.instrument.LiveInstrument
23+
import spp.protocol.instrument.event.LiveBreakpointHit
24+
import spp.protocol.instrument.event.LiveLogHit
2325

2426
/**
2527
* Listen to [LiveInstrument] events for the given [subscriptionId].
@@ -42,3 +44,37 @@ fun Vertx.addLiveInstrumentListener(
4244
}
4345
return promise.future()
4446
}
47+
48+
/**
49+
* Listen to [LiveBreakpointHit] events for the given [subscriptionId].
50+
*
51+
* @param subscriptionId the subscription id (can be developer id or instrument id)
52+
* @param listener the listener to be called when a breakpoint hit event is received
53+
*/
54+
fun Vertx.addBreakpointHitListener(
55+
subscriptionId: String,
56+
listener: (LiveBreakpointHit) -> Unit
57+
): Future<LiveInstrumentListenerImpl> {
58+
return addLiveInstrumentListener(subscriptionId, object : LiveInstrumentListener {
59+
override fun onBreakpointHitEvent(event: LiveBreakpointHit) {
60+
listener(event)
61+
}
62+
})
63+
}
64+
65+
/**
66+
* Listen to [LiveLogHit] events for the given [subscriptionId].
67+
*
68+
* @param subscriptionId the subscription id (can be developer id or instrument id)
69+
* @param listener the listener to be called when a log hit event is received
70+
*/
71+
fun Vertx.addLogHitListener(
72+
subscriptionId: String,
73+
listener: (LiveLogHit) -> Unit
74+
): Future<LiveInstrumentListenerImpl> {
75+
return addLiveInstrumentListener(subscriptionId, object : LiveInstrumentListener {
76+
override fun onLogHitEvent(event: LiveLogHit) {
77+
listener(event)
78+
}
79+
})
80+
}

0 commit comments

Comments
 (0)