updated to use the sample generated events

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-11 12:45:17 -07:00
parent 0067c55003
commit b49aed2de0
1 changed files with 9 additions and 16 deletions

View File

@ -8,7 +8,7 @@ import "io"
import "bytes"
import "github.com/golang/protobuf/proto"
import pb "git.wit.com/jcarr/witProtobuf"
import pb "git.wit.com/wit/witProtobuf"
var mychannel chan *pb.Event
@ -20,16 +20,16 @@ func initChannel() {
func processEvents() {
for {
message := <-mychannel
log.Println("processEvents() on channel recieved a message")
log.Println("processEvents() on channel recieved a message = ", message)
ReadReceivedData(message)
}
}
func ReadReceivedData(data *pb.Event) {
msgItems := data.GetResults()
fmt.Println("Receiving data...")
log.Println("ReadReceivedData() Event msgItems=", msgItems)
for _, item := range msgItems {
fmt.Println(item)
log.Println(item)
}
}
@ -42,7 +42,7 @@ func handleProtoClient(conn net.Conn) {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
return
}
pdata := new(pb.Event)
pdata := pb.CreateSampleEvent()
err = proto.Unmarshal(buf.Bytes(), pdata)
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
@ -52,8 +52,8 @@ func handleProtoClient(conn net.Conn) {
}
func addEvent() {
msg := new(pb.Event)
msg.Name = "hello jeff"
msg := pb.CreateSampleEvent()
msg.Name = "generated in addEvent()"
// var mybuf bytes.Buffer
@ -69,17 +69,10 @@ func addEvent() {
// writeBytesToSocket(data)
}
func createProtobufEvent() *pb.Event {
msg := new(pb.Event)
msg.Name = "hello jeff"
return msg
}
func sendEventToWIT() {
msg := createProtobufEvent()
var mybuf []byte
msg := pb.CreateSampleEvent()
var mybuf []byte
mybuf, err := proto.Marshal(msg)
if (err != nil) {
log.Printf("something fucked up happened")