Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# XXClient Quick Start Guide
Add `XXClient` library as a dependency to your project using Swift Package Manager.
## ▶️ Instantiating cMix
You can use a convenient `CMixManager` wrapper to manage cMix stored on disk:
```swift
let cMixManager: CMixManager = .live(
passwordStorage: .init(
save: { password in
// securely save provided password
},
load: {
// load securely stored password
}
)
)
let cMix: CMix
if cMixManager.hasStorage() {
cMix = try cMixManager.load()
} else {
cMix = try cMixManager.create()
}
```
Check out included example iOS application for the `PasswordStorage` implementation that uses the iOS keychain.
## ▶️ Connecting to the network
Start network follower:
```swift
try cMix.startNetworkFollower(timeoutMS: 10_000)
```
Wait until connected:
```swift
let isNetworkHealthy = try cMix.waitForNetwork(timeoutMS: 30_000)
```
## ▶️ Making a new reception identity
Use the cMix to make a new reception identity:
```swift
let myIdentity = try cMix.makeReceptionIdentity()
```
## ▶️ Create new E2E
```swift
let login: Login = .live
let e2e = try login(
cMixId: cMix.getId(),
identity: myIdentity
)
```
## ▶️ Connecting to remote
Perform auth key negotiation with the given recipient to get the `Connection`:
```swift
let connection = try cMix.connect(
withAuthentication: false,
e2eId: e2e.getId(),
recipientContact: ...
)
```
Pass `true` for the `withAuthentication` parameter if you want to prove id ownership to remote as well.
## ▶️ Sending messages
Send a message to the connection's partner:
```swift
let sendReport = try connection.send(
messageType: 1,
payload: ...
)
```
Check if the round succeeded:
```swift
try cMix.waitForRoundResult(
roundList: try sendReport.encode(),
timeoutMS: 30_000,
callback: .init { result in
switch result {
case .delivered(let roundResults):
...
case .notDelivered(let timedOut):
...
}
}
)
```
## ▶️ Receiving messages
Use connection's message listener to receive messages from partner:
```swift
try connection.registerListener(
messageType: 1,
listener: .init { message in
...
}
)
```