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
GitLab 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
Commits
998f36c9
Commit
998f36c9
authored
Jul 7, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Write README for connect client
parent
529abbdc
No related branches found
No related tags found
1 merge request
!5
Connections readme
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
connectClient/README.md
+81
-0
81 additions, 0 deletions
connectClient/README.md
connectServer/go.mod
+1
-1
1 addition, 1 deletion
connectServer/go.mod
connectServer/go.sum
+2
-2
2 additions, 2 deletions
connectServer/go.sum
connectServer/main.go
+16
-2
16 additions, 2 deletions
connectServer/main.go
with
100 additions
and
5 deletions
connectClient/README.md
+
81
−
0
View file @
998f36c9
# xxdk Connect Client Example
This mini-repository contains the example logic for running a basic connection
client. This is provided by the xx network team as a springboard to
help consumers better understand our API and how it may be used.
`main.go`
contains the crux of the logic. We avoid complicating our example by
avoiding the usage of CLI flags for basic variables you may change in the code.
This file initiates an xxdk E2E client. With that established, a connection
client is built on top. Using a precanned contact object created in
`connectServer`
this connection client contacts the server with a simple
message.
`utils.go`
contains utility functions for running the program. In this case,
we provide a tool initializing a log.
`listener.go`
contains logic for handling the reception of a message via the
established connection. In this example, it is very basic. We invite consumers
to use this as a basis to implement more complex message listeners here.
## Build Instructions
In these instructions we will go over building a connection client using our
example. In order to build a client which successfully sends a message through
the connection, we must first go over how to build and run a connection server.
### Building a Server
In order to run a server, the following commands may be run:
```
bash
cd
connectServer/
go build
-o
server
.
./server
```
This will initialize the server. You may verify its functionality by checking
the
`server.log`
file. It is a long-running process which may be
stopped by a user inputted kill signal. This will create a file
`connectServer.xxc`
, which is the contat file for the server. A connection
client may parse this file in order to send a request to this server.
### Building a Client
Please follow the steps above before continuing to these instructions.
In order to run the client, you must first move the aforementioned
`connectServer.xxc`
file to the path where you will run the client.
```
bash
cd
connectServer/
cp
connectServer.xxc /path/to/connectClient
```
Once the contact object is local to the client, you may build and run
the client:
```
bash
cd
connectClient/
go build
-o
client
.
./client
```
This is a long-running process which may be stopped by a user inputted kill
signal. We recommend allowing the process to run for a long enough time to
complete its requests to the server and receive the server's responses. We go
into detail on what this entails below.
Once the connection client has set up and established its connection with the
server, you can verify by checking the server's log for the string
`Message received`
.
```
bash
grep
"Message received"
server.log
INFO 2022/07/07 12:59:12.088046 Message received:
{
XxMessage WjdMwCH+...
[
73 102 32 116 104 105 115 32 109 101 115 115 97 103 101 32 105 115 32 115 101 110 116 32 115 117 99 99 101 115 115 102 117 108 108 121 44 32 119 101 39 108 108 32 104 97 118 101 32 101 115 116 97 98 108 105 115 104 101 100 32 99 111 110 116 97 99 116 32 119 105 116 104 32 116 104 101 32 115 101 114 118 101 114 46] kuycotVTjefJ4nZWJ+Ksg9/jviANn6suteW6HPmXroID l74No/qjr/8Q74mA9VadudforXet8OykqSvPIEFAeUQD
[
0 0 0 0 0 2 245 150] 2022-07-07 12:59:07.078570118
-0700
PDT
true
{
58339144 QUEUED 0xc001e12780 map[PENDING:1969-12-31 16:00:01.65722394
-0800
PST PRECOMPUTING:2022-07-07 12:59:00.644730058
-0700
PDT STANDBY:2022-07-07 12:59:07.062879269
-0700
PDT QUEUED:2022-07-07 12:59:10.062881354
-0700
PDT]
[]
1000 18 187058678 ID:58339144 UpdateID:187058678 State:3 BatchSize:1000 Topology:
"3
\x
dd
\x
c9;
\x
ce
\x
c5
\x
f0
\x
ff&
\x
8c
\x
f1
\x
7f
\n
f
\x
a8K
\x
17
\x
b6
\x
d1
\x
0b|a
\t
[
\x
14
\x
8e
\x
de
\x
d1qϊB
\x
02"
Topology:
"
\x
f5
\\\x
94MB
\x
19ڣq݃
\x
bee
\x
99
\x
bfF
\x
b5
\x
a9
\x
f3k
\x
0e8 gl
\x
f5:d
\x
11
\x
ab
\x
89
\x
17
\x
02"
Topology:
"
\x
01
\x
c1
\x
f6Gi
\x
972p
\x
a9
\x
96
\x
b4
\x
12
\x
0f1
\x
1c
\x
ebw
\x
ef
\x
ca
\x
ed
\"
F
\x
a7w
\x
e2
\n\x
bb8
\x
cbd
\x
05=
\x
02"
Topology:
"
\x
d5
\x
c3
\x
d00
\x
a3a;RqDs
\x
f0
\x
da<
\x
a3)
$y
\x
ef
\x
c1
\x
a0
\x
12_k?
\x
00
\r
IebL
\x
fe
\x
02"
Topology:
"vQ
\x
cd
\t\x
af
\x
91ڤ
\x
86
\x
8ecl
\x
84
\x
b1
\x
95
\x
1e
\x
8f+ږQ
\\
ﷀ]7
\x
89
\x
08
\x
02"
Timestamps:1657223940 Timestamps:1657223940644730058 Timestamps:1657223947062879269 Timestamps:1657223950062881354 Timestamps:0 Timestamps:0 Timestamps:0 ResourceQueueTimeoutMillis:3906340864 AddressSpaceSize:18 EccSignature:
{
Nonce:
"
\x
b2y
\x
ccf
\x
86E
\x
e0NR
\x
d2J3|
\x
b8d
\x
fe
\x
b3
\x
a8
\x
ad
\x
a2
\x
92
\x
e0
\x
e4
\x
0bZ
\x
07
\x
beٓ
\x
b4z
\x
f2"
Signature:
"
\x
e1
\x
c9
\x
92_
\x
fe
\x
9d
\x
7f
\x
18
\x
b920C
\x
a6
\x
d1
\x
e9U
\x
bb
\x
93o
\x
9b
\x
1bp<Y
\x
b1
\x
9f
\x
b7O
\x
012^^
\x
9doa
\x
06P
\x
83
\x
fes
\x
bf
\x
e1
\x
aeL
\x
b0+
\\\x
dc
\x
12r4)
\x
das49
\x
f6=
\x
d2
\x
13
\x
a0
\x
07"
}}}
```
By default, the client sends a single message to the server, with the server
registering a
`receive.Listener`
which listens to messages of type
`catalog.NoType`
from the client. The server does not send a message back in
this example.
This diff is collapsed.
Click to expand it.
connectServer/go.mod
+
1
−
1
View file @
998f36c9
...
@@ -4,7 +4,7 @@ go 1.17
...
@@ -4,7 +4,7 @@ go 1.17
require (
require (
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/jwalterweatherman v1.1.0
gitlab.com/elixxir/client v1.5.1-0.2022070
5214402-3ebd3c1fcfec
gitlab.com/elixxir/client v1.5.1-0.2022070
7193810-ed09e1277c6d
gitlab.com/elixxir/crypto v0.0.7-0.20220606201132-c370d5039cea
gitlab.com/elixxir/crypto v0.0.7-0.20220606201132-c370d5039cea
gitlab.com/xx_network/primitives v0.0.4-0.20220630163313-7890038258c6
gitlab.com/xx_network/primitives v0.0.4-0.20220630163313-7890038258c6
)
)
...
...
This diff is collapsed.
Click to expand it.
connectServer/go.sum
+
2
−
2
View file @
998f36c9
...
@@ -253,8 +253,8 @@ github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm
...
@@ -253,8 +253,8 @@ github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm
github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f h1:yXGvNBqzZwAhDYlSnxPRbgor6JWoOt1Z7s3z1O9JR40=
gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f h1:yXGvNBqzZwAhDYlSnxPRbgor6JWoOt1Z7s3z1O9JR40=
gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k=
gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k=
gitlab.com/elixxir/client v1.5.1-0.2022070
5214402-3ebd3c1fcfec h1:TpO05QgOP3sa0V3KGhOWy6k80YYCvpH/I6/hgwVcpxY
=
gitlab.com/elixxir/client v1.5.1-0.2022070
7193810-ed09e1277c6d h1:MxseLDnuqGkrnlDDzlH7AYlfm6qPDfy2wf2Qlt4AZbQ
=
gitlab.com/elixxir/client v1.5.1-0.2022070
5214402-3ebd3c1fcfec
/go.mod h1:GCevkp2aa+vpIsSrlF/HsRlTjf107jgCglZ/0JKqW7E=
gitlab.com/elixxir/client v1.5.1-0.2022070
7193810-ed09e1277c6d
/go.mod h1:GCevkp2aa+vpIsSrlF/HsRlTjf107jgCglZ/0JKqW7E=
gitlab.com/elixxir/comms v0.0.4-0.20220603231314-e47e4af13326 h1:Zid8oNHtbOqF6ebrcGIccvIMabFNGh9dzY1b7mgIcF0=
gitlab.com/elixxir/comms v0.0.4-0.20220603231314-e47e4af13326 h1:Zid8oNHtbOqF6ebrcGIccvIMabFNGh9dzY1b7mgIcF0=
gitlab.com/elixxir/comms v0.0.4-0.20220603231314-e47e4af13326/go.mod h1:tlHSrtSliKWUxsck8z/Ql/VJkMdSONV2BeWaUAAXzgk=
gitlab.com/elixxir/comms v0.0.4-0.20220603231314-e47e4af13326/go.mod h1:tlHSrtSliKWUxsck8z/Ql/VJkMdSONV2BeWaUAAXzgk=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
...
...
This diff is collapsed.
Click to expand it.
connectServer/main.go
+
16
−
2
View file @
998f36c9
...
@@ -9,6 +9,8 @@ import (
...
@@ -9,6 +9,8 @@ import (
"io/fs"
"io/fs"
"io/ioutil"
"io/ioutil"
"os"
"os"
"os/signal"
"syscall"
"time"
"time"
"gitlab.com/elixxir/client/connect"
"gitlab.com/elixxir/client/connect"
...
@@ -16,7 +18,7 @@ import (
...
@@ -16,7 +18,7 @@ import (
func
main
()
{
func
main
()
{
// Logging
// Logging
initLog
(
1
,
"
client
.log"
)
initLog
(
1
,
"
server
.log"
)
// Create a new client object-------------------------------------------------------
// Create a new client object-------------------------------------------------------
...
@@ -153,5 +155,17 @@ func main() {
...
@@ -153,5 +155,17 @@ func main() {
// Keep app running to receive messages-----------------------------------------------
// Keep app running to receive messages-----------------------------------------------
select
{}
// Wait until the user terminates the program
c
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
<-
c
err
=
connectServer
.
E2e
.
StopNetworkFollower
()
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to stop network follower: %+v"
,
err
)
}
else
{
jww
.
INFO
.
Printf
(
"Stopped network follower."
)
}
os
.
Exit
(
0
)
}
}
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