actually sends the protobuf into the channel
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
8807c8fc9b
commit
2e4bbf7b91
|
@ -52,10 +52,8 @@ func handleProtoClient(conn net.Conn) {
|
|||
mychannel <- pdata
|
||||
}
|
||||
|
||||
func addEvent() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
msg.Name = "generated in addEvent()"
|
||||
|
||||
// Marshal & Unmarshal just to see if it ever fails
|
||||
func addEvent(msg *pb.Event) {
|
||||
data, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("addEvent() something fucked up happened in Marshal")
|
||||
|
@ -70,6 +68,24 @@ func addEvent() {
|
|||
mychannel <- pdata
|
||||
}
|
||||
|
||||
func addSampleEvent() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
msg.Name = "generated in addSampleEvent()"
|
||||
|
||||
data, err := proto.Marshal(msg)
|
||||
if (err != nil) {
|
||||
log.Printf("addSampleEvent() something fucked up happened in Marshal")
|
||||
}
|
||||
|
||||
pdata := new(pb.Event)
|
||||
err = proto.Unmarshal(data, pdata)
|
||||
if (err != nil) {
|
||||
log.Printf("addSampleEvent() something fucked up happened in Unmarshal")
|
||||
}
|
||||
|
||||
mychannel <- pdata
|
||||
}
|
||||
|
||||
func sendEventToWIT() {
|
||||
msg := pb.CreateSampleEvent()
|
||||
|
|
@ -26,12 +26,13 @@ func readGorillaConn(conn *websocket.Conn) {
|
|||
return
|
||||
}
|
||||
if (mytype == websocket.BinaryMessage) {
|
||||
pdata := new(pb.Event)
|
||||
err = proto.Unmarshal(message, pdata)
|
||||
protobufMsg := new(pb.Event)
|
||||
err = proto.Unmarshal(message, protobufMsg)
|
||||
if (err != nil) {
|
||||
log.Printf("readConn() something fucked up happened in Unmarshal")
|
||||
}
|
||||
log.Printf("recv binary: %s", pdata)
|
||||
log.Printf("readGorillaConn() successfully read protobuf from gorilla websocket")
|
||||
addEvent(protobufMsg)
|
||||
} else {
|
||||
log.Printf("recv: %s", message)
|
||||
// log.Printf("type, err = ", mytype, err)
|
||||
|
|
19
infoTabUI.go
19
infoTabUI.go
|
@ -61,7 +61,7 @@ func makeCloudInfoBox() ui.Control {
|
|||
add3button := ui.NewButton("Add buf to chann")
|
||||
add3button.OnClicked(func(*ui.Button) {
|
||||
log.Println("add protobuf event to the channel")
|
||||
addEvent()
|
||||
addSampleEvent()
|
||||
})
|
||||
vbox.Append(add3button, false)
|
||||
|
||||
|
@ -170,3 +170,20 @@ func addTableTab() {
|
|||
time.Sleep(1 * 1000 * 1000 * 1000)
|
||||
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
||||
}
|
||||
|
||||
func addProtobufTab() {
|
||||
var parts []gui.InputData
|
||||
|
||||
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
||||
log.Println(key, foo)
|
||||
|
||||
var b gui.InputData
|
||||
b.CellType = foo
|
||||
b.Heading = fmt.Sprintf("heading%d", key)
|
||||
parts = append(parts, b)
|
||||
}
|
||||
|
||||
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
||||
time.Sleep(1 * 1000 * 1000 * 1000)
|
||||
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue