This commit is contained in:
Martin Geno 2016-02-19 13:28:06 +01:00
parent 43a9b30fd2
commit 88b0cb22ca
3 changed files with 10 additions and 7 deletions

View File

@ -112,9 +112,16 @@ func (coll *Collector) parse(res *Response) {
// Set result // Set result
elem := reflect.ValueOf(node).Elem() elem := reflect.ValueOf(node).Elem()
field := elem.FieldByName(strings.Title(coll.collectType)) field := elem.FieldByName(strings.Title(coll.collectType))
field.Set(reflect.ValueOf(result))
log.Println(field)
log.Println(result)
if !reflect.DeepEqual(field,result){
nodeserver.SendAll(node) nodeserver.SendAll(node)
log.Println("get a node update")
}
field.Set(reflect.ValueOf(result))
} }
func (coll *Collector) receiver() { func (coll *Collector) receiver() {

View File

@ -2,7 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"log"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
) )
@ -58,18 +57,16 @@ func (c *NodeClient) Done() {
// Listen Write and Read request via chanel // Listen Write and Read request via chanel
func (c *NodeClient) Listen() { func (c *NodeClient) Listen() {
go c.listenWrite() c.listenWrite()
} }
// Listen write request via chanel // Listen write request via chanel
func (c *NodeClient) listenWrite() { func (c *NodeClient) listenWrite() {
log.Println("Listening write to NodeClient")
for { for {
select { select {
// send message to the client // send message to the client
case node := <-c.ch: case node := <-c.ch:
log.Println("Send:", node)
websocket.JSON.Send(c.ws, node) websocket.JSON.Send(c.ws, node)
// receive done request // receive done request

View File

@ -102,7 +102,6 @@ func (s *NodeServer) Listen() {
// broadcast message for all clients // broadcast message for all clients
case node := <-s.sendAllCh: case node := <-s.sendAllCh:
log.Println("Send all:", node)
s.sendAll(node) s.sendAll(node)
case err := <-s.errCh: case err := <-s.errCh: