You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f630082
Browse filesBrowse the repository at this point in the historyBrowse files
The `catnet-core` engine exposes a stream of typed events during scan execution to allow consumers (CLI, TUI, GUI) to react to progress and lifecycle changes without coupling to internal logic.
4
+
5
+
## Event Signature
6
+
7
+
Events are dispatched synchronously via the `engine.EventCallback` function:
8
+
```go
9
+
typeEventCallbackfunc(event ScanEvent)
10
+
```
11
+
12
+
## ScanEvent Struct
13
+
14
+
```go
15
+
typeScanEventstruct {
16
+
TypeScanEventType
17
+
Device *results.DeviceInfo
18
+
Progressfloat64
19
+
Messagestring
20
+
}
21
+
```
22
+
23
+
## Event Types
24
+
25
+
| Type | Description | Included Data |
26
+
|------|-------------|---------------|
27
+
|`EventLifecycleStart`| Fired once when `StartScan` is invoked. |`Message`|
28
+
|`EventLifecycleComplete`| Fired once when `StartScan` completes successfully. |`Message`|
29
+
|`EventLifecycleCancel`| Fired once when the scan is cancelled or times out. |`Message`|
30
+
|`EventWarning`| Fired when a non-fatal error occurs (e.g. permission issues). |`Message`|
31
+
|`EventProgress`| Fired periodically to indicate scan progress. |`Progress` (0.0 to 1.0) |
32
+
|`EventResult`| Fired when a device scan completes (whether alive or dead). |`Device`|
33
+
34
+
## Consumer Responsibilities
35
+
36
+
1.**Non-blocking callbacks:** Event callbacks are executed synchronously by the engine's worker goroutines. Consumers **must not** perform long-blocking operations in the callback. If processing requires heavy I/O, dispatch it to a channel or separate goroutine.
37
+
2.**Thread safety:** The `Device` pointer in `EventResult` points to a copied value, but consumers should avoid mutating it.
0 commit comments