fix: Re-initializing after I destroyed the original repository.

This commit is contained in:
James Wells 2021-02-25 17:46:40 -08:00
parent 5863999e8c
commit 8b54fc32c5
Signed by: jwells
GPG key ID: 73196D10B8E65666
20 changed files with 1359 additions and 0 deletions

43
src/client/client.go Normal file
View file

@ -0,0 +1,43 @@
package client
import (
"fmt"
"sync"
"time"
gs "git.dragonheim.net/dragonheim/gagent/src/gstructs"
zmq "github.com/pebbe/zmq4"
)
// Main is the initiation function for a Client
func Main(config gs.GagentConfig, agent string) {
var mu sync.Mutex
fmt.Printf("Did we make it this far?\n")
fmt.Printf("--|%#v|--\n", agent)
connectString := fmt.Sprintf("tcp://%s", config.Routers[0].RouterAddr)
sock, _ := zmq.NewSocket(zmq.DEALER)
defer sock.Close()
sock.SetIdentity(config.UUID)
sock.Connect(connectString)
go func() {
mu.Lock()
sock.SendMessage(agent)
mu.Unlock()
}()
for {
time.Sleep(10 * time.Millisecond)
mu.Lock()
msg, err := sock.RecvMessage(zmq.DONTWAIT)
if err == nil {
fmt.Println(msg[0], config.UUID)
}
mu.Unlock()
}
}