You will need to import a few more packages along the way. However, we want to avoid unused import warnings from the compiler, so we will include them as needed. It is straightforward to switch the external libraries out for any alternatives you prefer.
You will need to import a few more packages along the way. However, we want to avoid unused import warnings from the compiler, so we will include them as needed.
:::tip
1. To ensure you are using the latest release version of the client, you can run `go get gitlab.com/elixxir/client@release`. This will update your `go.mod` file automatically.
...
...
@@ -132,40 +129,45 @@ Here is how we have set up `NewClient()` in our messaging app:
// You would ideally use a configuration tool to acquire these parameters
statePath:="statePath"
statePass:="password"
// The following connects to mainnet. For historical reasons, it is called a json file
// The following connects to mainnet. For historical reasons it is called a json file
// but it is actually a marshalled file with a cryptographic signature attached.
jww.FATAL.Panicf("Failed to create new client: %+v",err)
fmt.Printf("Failed to create new client: %+v",err)
}
}
```
There are two crucial steps here.
1. You need to get an NDF, which you may already have from the [*Download an NDF*](#download-an-ndf) step. In the code above, we attempt to read from a file first, then try to download the release NDF with`DownloadAndVerifySignedNdfWithUrl()`, which dynamically downloads the NDF data a client needs from a specified URL. It takes two arguments:
-`url`: A publicly accessible URL pointing to the NDF data.
-`cert`: The certificate for the scheduling/registration server.
1. You need to get an NDF, which you may already have from the [*Download an NDF*](#download-an-ndf) step. In the code above, we attempt to read from a file first, then try to download the mainnet NDF with`DownloadAndVerifySignedNdfWithUrl()`, which dynamically downloads the NDF data a client needs from a specified URL. It takes two arguments:
-`url`: A publicly accessible URL pointing to the NDF data. It is a `string` type.
-`cert`: The certificate for the scheduling/registration server. Note that this is the actual certificate, not the path to it. It is a `string` type
:::note
There are multiple URL/certificate pairs associated with different environments. It is extremely important to use the correct pair for your specific environment. These include:
...
...
@@ -201,7 +203,7 @@ The `Login()` function expects the same session directory and password used to c
// Assumes you have imported "gitlab.com/elixxir/client/interfaces/params"
The switchboard from `GetSwitchboard()` is used for interprocess signaling about received messages. On the other hand, `RegisterChannel()` registers a new listener built around the passed channel (in this case, `receiverChannel`). Here is the function signature for `RegisterChannel()`:
For our messaging app, we have also set up a function that waits until the network is healthy. Here is our sample code for starting network threads and waiting until the network is healthy:
```go
// Set networkFollowerTimeout to a value of your choice (type is of `time.Duration`)
networkFollowerTimeout:=5*time.Second
// Set networkFollowerTimeout to a value of your choice (seconds)
jww.INFO.Printf("Requested auth channel from: %s in round %d",
fmt.Printf("Requested auth channel from: %s in round %d",
recipientID,roundID)
}else{
jww.FATAL.Panicf("%+v",err)
fmt.Printf("%+v",err)
}
```
...
...
@@ -380,11 +382,11 @@ type Contact struct {
We are running multiple client instances locally to test out authenticated channels for our messaging app. Although not the most ideal way to get it, this means that we can also fetch the recipient's contact details from CLI-generated contact files:
```go
// Sender's contact
// Sender's contact for requesting auth channels
me:=client.GetUser().GetContact()
// Recipient's contact (read from a Client CLI-generated contact file)