Skip to content

Commit

Permalink
call tunnel provider initcb on first event (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
scareything authored Oct 18, 2023
1 parent 1cba12e commit 3726828
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Ziti.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import CZitiPrivate
/// Opaque reference to Ziti SDK C context
public var ztx:OpaquePointer?
/// received first event from C sdk.
private var eventReceived = false
public var eventReceived = false

/// Access to the `ZitiTunnel` managing this instance (if applicable)
public weak var zitiTunnel:ZitiTunnel?
Expand Down
9 changes: 4 additions & 5 deletions lib/ZitiTunnel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,10 @@ public class ZitiTunnel : NSObject, ZitiUnretained {
return
}

// Update ztx (not available until loop is running...), call initCallback
let key = "\(KEY_ZITI_INSTANCE)\(ziti.id.id)"
if ziti.ztx == nil, let zi = ziti.userData[key] as? UnsafeMutablePointer<ziti_instance_s>, let ztx = zi.pointee.ztx {
ziti.ztx = ztx
Ziti.postureContexts[ztx] = ziti
// call initCallback on our first event
if !ziti.eventReceived {
ziti.eventReceived = true
Ziti.postureContexts[ziti.ztx!] = ziti
mySelf.tunnelProvider?.initCallback(ziti, nil)
}

Expand Down

0 comments on commit 3726828

Please sign in to comment.