func main() { dcams.ManifestFileName = "fakeClient.manifest" fakeClient, err := dcams.Open() if err != nil { //What do we need: 1 pull REQ, err := dcams.NewREQ("springInput") dieOnErr(err) fakeClient.Add(REQ) fakeClient.WriteFile() log.Printf("fakeClient REQ key: [\"%s\"]", REQ.PublicKey) log.Fatal("Manually swap keys with remote client trusted list!") } log.Println("Connect") err = fakeClient.Connect() dieOnErr(err) m := Location{Id: "blah", Neighbors: []string{}, Frq: 1.618} mmsg, _ := json.Marshal(m) log.Println(string(mmsg)) err = fakeClient.Resource("springInput").Write(string(mmsg)) dieOnErr(err) asd, err := fakeClient.Resource("springInput").Read() dieOnErr(err) log.Println("ClientFinal", asd) }
//connect and read all data published by the simulation side of things func eventsClient() { dcams.ManifestFileName = "web.manifest" web, err := dcams.Open() if err != nil { //What do we need: 1 sub, 1 REQ sub, err := dcams.NewSub("springData") dieOnErr(err) web.Add(sub) REQ, err := dcams.NewREQ("springInput") dieOnErr(err) web.Add(REQ) web.WriteFile() log.Printf("springdata subscribe key: [\"%s\"]", sub.PublicKey) log.Printf("springdata REQ key: [\"%s\"]", REQ.PublicKey) log.Println("Manually swap keys with remote client trusted list!") return //skips the connect } web.Connect() // handles messages coming from user go eventRequester(web) //handles messages going to users. Each websocket reads the publish for { mNodeState, err := web.Resource("springData").Read() if err != nil { continue } var newdata Nodes if err := json.Unmarshal([]byte(mNodeState), &newdata); err != nil { //ignore things that arent Nodess marshalled as json continue } //log.Println(NodeState) publish <- newdata } }