func MakeReceiver() *receiver.Receiver { aReceiver, err := receiver.NewReceiver("239.192.0.0:5000") if err != nil { panic("Error creating receiver:" + err.Error()) } return aReceiver }
func main() { receiver, err := receiver.NewReceiver("239.192.0.0:5000") if err != nil { fmt.Println("Error creating receiver:", err) return } incoming := receiver.MessagesChannel() for { packet := <-incoming fmt.Println("Read", len(packet.Data), "bytes:", string(packet.Data), "Remote:", packet.Remote()) dummy := header.MakeFixedSignature("DummyMsg") req, err := header.MakeRequest(dummy, []byte{}) if err != nil { fmt.Println("Could not make request:", err) } else { err = receiver.SendCommand(req, packet.Remote()) if err != nil { fmt.Println("Command not sent, error:", err) } } } }