//AddVisual adds a visual received from the chronicle func (c *Core) AddVisual(vis *mrclean.Visual, reply *int) error { c.Lock.Lock() defer c.Lock.Unlock() //c.Visuals[vis.Name] = vis *reply = 0 log.Printf("Received visual %+v\n", vis) //adding visual to the display rvis := mrclean.Visual{ //Origin: make([]float64, 2), //Size: make([]float64, 2), } err := client.Call("Display.AddVisual", vis, &rvis) if err != nil { log.Println(err) //maye just return nil? chronicle cannot do much a this point *reply = -1 return err } //the rpc result has the missing data so we update the visual and put it in the map vis.Origin = rvis.Origin vis.Size = rvis.Size vis.ID = rvis.ID c.Visuals[vis.Name] = vis log.Printf("Added visual %+v\n", vis) log.Println("len(Visuals) ", len(c.Visuals)) c.mx = math.Max(c.mx, vis.Size[0]) c.my = math.Max(c.my, rvis.Size[1]) return nil }
// The Display methods signatures follow the RPC rules // See http://golang.org/pkg/net/rpc/ func (d *Display) AddVisual(vis *mrclean.Visual, reply *mrclean.Visual) error { dcvis, err := d.client.AddVisual(*vis) if err != nil { return err } //log.Printf("Adding Visual: %+v\n\n\n\n\n", *vis) //log.Printf("Received Visual: %+v\n\n\n\n", *dcvis) //reply = &mrclean.Visual{} //*reply = *vis reply.Origin = make([]float64, 2) reply.Size = make([]float64, 2) //fill the remaining fields reply.Origin[0], reply.Origin[1] = dcvis.Origin[0], dcvis.Origin[1] reply.Size[0], reply.Size[1] = dcvis.Size[0], dcvis.Size[1] reply.ID = dcvis.ID return nil //fmt.Errorf("not implemented") }