Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk Examples
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
elixxir
xxdk Examples
Merge requests
!6
Rest connect
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Rest connect
RestConnect
into
master
Overview
0
Commits
7
Pipelines
0
Changes
1
Merged
Josh Brooks
requested to merge
RestConnect
into
master
2 years ago
Overview
0
Commits
7
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
86ee1034
Prev
Next
Show latest version
1 file
+
10
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
86ee1034
Refer to xxdk.Cmix/E2E as net/messenger
· 86ee1034
Josh Brooks
authored
2 years ago
e2eClient/main.go
+
10
−
10
Options
@@ -71,21 +71,21 @@ func main() {
// Login to your client session-----------------------------------------------------
// Login with the same sessionPath and sessionPass used to call NewClient()
baseClie
nt
,
err
:=
xxdk
.
LoadCmix
(
statePath
,
[]
byte
(
statePass
),
xxdk
.
GetDefaultCMixParams
())
n
e
t
,
err
:=
xxdk
.
LoadCmix
(
statePath
,
[]
byte
(
statePass
),
xxdk
.
GetDefaultCMixParams
())
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to load state: %+v"
,
err
)
}
// Get reception identity (automatically created if one does not exist)
identityStorageKey
:=
"identityStorageKey"
identity
,
err
:=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
baseClie
nt
)
identity
,
err
:=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
n
e
t
)
if
err
!=
nil
{
// If no extant xxdk.ReceptionIdentity, generate and store a new one
identity
,
err
=
xxdk
.
MakeReceptionIdentity
(
baseClie
nt
)
identity
,
err
=
xxdk
.
MakeReceptionIdentity
(
n
e
t
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to generate reception identity: %+v"
,
err
)
}
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
baseClie
nt
)
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
n
e
t
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to store new reception identity: %+v"
,
err
)
}
@@ -98,17 +98,17 @@ func main() {
params
:=
xxdk
.
GetDefaultE2EParams
()
jww
.
INFO
.
Printf
(
"Using E2E parameters: %+v"
,
params
)
confirmChan
:=
make
(
chan
contact
.
Contact
,
5
)
xxdkClient
,
err
:=
xxdk
.
Login
(
baseClie
nt
,
&
auth
{
confirmChan
:
confirmChan
},
identity
,
params
)
messenger
,
err
:=
xxdk
.
Login
(
n
e
t
,
&
auth
{
confirmChan
:
confirmChan
},
identity
,
params
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Unable to Login: %+v"
,
err
)
}
e2eClient
:=
xxdkClient
.
GetE2E
()
e2eClient
:=
messenger
.
GetE2E
()
// Start network threads------------------------------------------------------------
// Set networkFollowerTimeout to a value of your choice (seconds)
networkFollowerTimeout
:=
5
*
time
.
Second
err
=
xxdkClient
.
StartNetworkFollower
(
networkFollowerTimeout
)
err
=
messenger
.
StartNetworkFollower
(
networkFollowerTimeout
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to start network follower: %+v"
,
err
)
}
@@ -133,7 +133,7 @@ func main() {
// Create a tracker channel to be notified of network changes
connected
:=
make
(
chan
bool
,
10
)
// Provide a callback that will be signalled when network health status changes
xxdkClient
.
GetCmix
()
.
AddHealthCallback
(
messenger
.
GetCmix
()
.
AddHealthCallback
(
func
(
isConnected
bool
)
{
connected
<-
isConnected
})
@@ -171,7 +171,7 @@ func main() {
// Check that the partner exists, if not send a request
_
,
err
=
e2eClient
.
GetPartner
(
recipientContact
.
ID
)
if
err
!=
nil
{
_
,
err
=
xxdkClient
.
GetAuth
()
.
Request
(
recipientContact
,
fact
.
FactList
{})
_
,
err
=
messenger
.
GetAuth
()
.
Request
(
recipientContact
,
fact
.
FactList
{})
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to send contact request to %s: %+v"
,
recipientContact
.
ID
.
String
(),
err
)
}
@@ -205,7 +205,7 @@ func main() {
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
<-
c
err
=
xxdkClient
.
StopNetworkFollower
()
err
=
messenger
.
StopNetworkFollower
()
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to stop network follower: %+v"
,
err
)
}
else
{
Loading