Skip to content
Snippets Groups Projects
Commit 86ee1034 authored by Josh Brooks's avatar Josh Brooks
Browse files

Refer to xxdk.Cmix/E2E as net/messenger

parent 0f0d7ae3
No related branches found
No related tags found
1 merge request!6Rest connect
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
...@@ -71,21 +71,21 @@ func main() { ...@@ -71,21 +71,21 @@ func main() {
// Login to your client session----------------------------------------------------- // Login to your client session-----------------------------------------------------
// Login with the same sessionPath and sessionPass used to call NewClient() // Login with the same sessionPath and sessionPass used to call NewClient()
baseClient, err := xxdk.LoadCmix(statePath, []byte(statePass), xxdk.GetDefaultCMixParams()) net, err := xxdk.LoadCmix(statePath, []byte(statePass), xxdk.GetDefaultCMixParams())
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to load state: %+v", err) jww.FATAL.Panicf("Failed to load state: %+v", err)
} }
// Get reception identity (automatically created if one does not exist) // Get reception identity (automatically created if one does not exist)
identityStorageKey := "identityStorageKey" identityStorageKey := "identityStorageKey"
identity, err := xxdk.LoadReceptionIdentity(identityStorageKey, baseClient) identity, err := xxdk.LoadReceptionIdentity(identityStorageKey, net)
if err != nil { if err != nil {
// If no extant xxdk.ReceptionIdentity, generate and store a new one // If no extant xxdk.ReceptionIdentity, generate and store a new one
identity, err = xxdk.MakeReceptionIdentity(baseClient) identity, err = xxdk.MakeReceptionIdentity(net)
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to generate reception identity: %+v", err) jww.FATAL.Panicf("Failed to generate reception identity: %+v", err)
} }
err = xxdk.StoreReceptionIdentity(identityStorageKey, identity, baseClient) err = xxdk.StoreReceptionIdentity(identityStorageKey, identity, net)
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to store new reception identity: %+v", err) jww.FATAL.Panicf("Failed to store new reception identity: %+v", err)
} }
...@@ -98,17 +98,17 @@ func main() { ...@@ -98,17 +98,17 @@ func main() {
params := xxdk.GetDefaultE2EParams() params := xxdk.GetDefaultE2EParams()
jww.INFO.Printf("Using E2E parameters: %+v", params) jww.INFO.Printf("Using E2E parameters: %+v", params)
confirmChan := make(chan contact.Contact, 5) confirmChan := make(chan contact.Contact, 5)
xxdkClient, err := xxdk.Login(baseClient, &auth{confirmChan: confirmChan}, identity, params) messenger, err := xxdk.Login(net, &auth{confirmChan: confirmChan}, identity, params)
if err != nil { if err != nil {
jww.FATAL.Panicf("Unable to Login: %+v", err) jww.FATAL.Panicf("Unable to Login: %+v", err)
} }
e2eClient := xxdkClient.GetE2E() e2eClient := messenger.GetE2E()
// Start network threads------------------------------------------------------------ // Start network threads------------------------------------------------------------
// Set networkFollowerTimeout to a value of your choice (seconds) // Set networkFollowerTimeout to a value of your choice (seconds)
networkFollowerTimeout := 5 * time.Second networkFollowerTimeout := 5 * time.Second
err = xxdkClient.StartNetworkFollower(networkFollowerTimeout) err = messenger.StartNetworkFollower(networkFollowerTimeout)
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to start network follower: %+v", err) jww.FATAL.Panicf("Failed to start network follower: %+v", err)
} }
...@@ -133,7 +133,7 @@ func main() { ...@@ -133,7 +133,7 @@ func main() {
// Create a tracker channel to be notified of network changes // Create a tracker channel to be notified of network changes
connected := make(chan bool, 10) connected := make(chan bool, 10)
// Provide a callback that will be signalled when network health status changes // Provide a callback that will be signalled when network health status changes
xxdkClient.GetCmix().AddHealthCallback( messenger.GetCmix().AddHealthCallback(
func(isConnected bool) { func(isConnected bool) {
connected <- isConnected connected <- isConnected
}) })
...@@ -171,7 +171,7 @@ func main() { ...@@ -171,7 +171,7 @@ func main() {
// Check that the partner exists, if not send a request // Check that the partner exists, if not send a request
_, err = e2eClient.GetPartner(recipientContact.ID) _, err = e2eClient.GetPartner(recipientContact.ID)
if err != nil { if err != nil {
_, err = xxdkClient.GetAuth().Request(recipientContact, fact.FactList{}) _, err = messenger.GetAuth().Request(recipientContact, fact.FactList{})
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to send contact request to %s: %+v", recipientContact.ID.String(), err) jww.FATAL.Panicf("Failed to send contact request to %s: %+v", recipientContact.ID.String(), err)
} }
...@@ -205,7 +205,7 @@ func main() { ...@@ -205,7 +205,7 @@ func main() {
signal.Notify(c, os.Interrupt, syscall.SIGTERM) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c <-c
err = xxdkClient.StopNetworkFollower() err = messenger.StopNetworkFollower()
if err != nil { if err != nil {
jww.ERROR.Printf("Failed to stop network follower: %+v", err) jww.ERROR.Printf("Failed to stop network follower: %+v", err)
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment