Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
95d29a63
Commit
95d29a63
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add MessageDeliveryWaiter
parent
d811b991
No related branches found
No related tags found
1 merge request
!2
Bindings API wrapper
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Client.swift
+5
-2
5 additions, 2 deletions
Sources/ElixxirDAppsSDK/Client.swift
Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift
+61
-0
61 additions, 0 deletions
Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift
with
66 additions
and
2 deletions
Sources/ElixxirDAppsSDK/Client.swift
+
5
−
2
View file @
95d29a63
...
...
@@ -5,6 +5,7 @@ public struct Client {
public
var
waitForNetwork
:
NetworkWaiter
public
var
makeIdentity
:
IdentityMaker
public
var
connect
:
ConnectionMaker
public
var
waitForDelivery
:
MessageDeliveryWaiter
}
extension
Client
{
...
...
@@ -13,7 +14,8 @@ extension Client {
networkFollower
:
.
live
(
bindingsClient
:
bindingsClient
),
waitForNetwork
:
.
live
(
bindingsClient
:
bindingsClient
),
makeIdentity
:
.
live
(
bindingsClient
:
bindingsClient
),
connect
:
.
live
(
bindingsClient
:
bindingsClient
)
connect
:
.
live
(
bindingsClient
:
bindingsClient
),
waitForDelivery
:
.
live
(
bindingsClient
:
bindingsClient
)
)
}
}
...
...
@@ -24,7 +26,8 @@ extension Client {
networkFollower
:
.
failing
,
waitForNetwork
:
.
failing
,
makeIdentity
:
.
failing
,
connect
:
.
failing
connect
:
.
failing
,
waitForDelivery
:
.
failing
)
}
#endif
This diff is collapsed.
Click to expand it.
Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift
0 → 100644
+
61
−
0
View file @
95d29a63
import
Bindings
public
struct
MessageDeliveryWaiter
{
public
struct
Result
:
Equatable
{
public
init
(
delivered
:
Bool
,
timedOut
:
Bool
,
roundResults
:
Data
?)
{
self
.
delivered
=
delivered
self
.
timedOut
=
timedOut
self
.
roundResults
=
roundResults
}
public
var
delivered
:
Bool
public
var
timedOut
:
Bool
public
var
roundResults
:
Data
?
}
public
var
wait
:
(
Data
,
Int
,
@escaping
(
Result
)
->
Void
)
throws
->
Void
public
func
callAsFunction
(
roundList
:
Data
,
timeoutMS
:
Int
,
callback
:
@escaping
(
Result
)
->
Void
)
throws
->
Void
{
try
wait
(
roundList
,
timeoutMS
,
callback
)
}
}
extension
MessageDeliveryWaiter
{
public
static
func
live
(
bindingsClient
:
BindingsClient
)
->
MessageDeliveryWaiter
{
MessageDeliveryWaiter
{
roundList
,
timeoutMS
,
callback
in
try
bindingsClient
.
wait
(
forMessageDelivery
:
roundList
,
mdc
:
Callback
(
onCallback
:
{
delivered
,
timedOut
,
roundResults
in
callback
(
Result
(
delivered
:
delivered
,
timedOut
:
timedOut
,
roundResults
:
roundResults
))
}),
timeoutMS
:
timeoutMS
)
}
}
}
private
final
class
Callback
:
NSObject
,
BindingsMessageDeliveryCallbackProtocol
{
init
(
onCallback
:
@escaping
(
Bool
,
Bool
,
Data
?)
->
Void
)
{
self
.
onCallback
=
onCallback
super
.
init
()
}
let
onCallback
:
(
Bool
,
Bool
,
Data
?)
->
Void
func
eventCallback
(
_
delivered
:
Bool
,
timedOut
:
Bool
,
roundResults
:
Data
?)
{
onCallback
(
delivered
,
timedOut
,
roundResults
)
}
}
#if DEBUG
extension
MessageDeliveryWaiter
{
public
static
let
failing
=
MessageDeliveryWaiter
{
_
,
_
,
_
in
struct
NotImplemented
:
Error
{}
throw
NotImplemented
()
}
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment