diff --git a/message.go b/message.go index 8f6acba..7c17211 100644 --- a/message.go +++ b/message.go @@ -68,8 +68,18 @@ func (m *message) check(dump bool) error { if br.Err() != nil { break } - e := entity{t: uint32(t), size: uint32(s), body: b} - fmt.Printf("\t%v\n", e) + fmt.Printf("\t%v\n", entity{t: uint32(t), size: uint32(s), body: b}) + e := entFactory.BuildMessage(int(t)) + if e == nil { + fmt.Printf("\tno known entity for type id %d\n", int(t)) + continue + } + err := proto.Unmarshal(b, e) + if err != nil { + fmt.Printf("entity unmarshal error: %v\n", err) + } else { + fmt.Printf("\t\t%v\n", e) + } } } return nil diff --git a/parser.go b/parser.go index 8680299..4106022 100644 --- a/parser.go +++ b/parser.go @@ -5,6 +5,7 @@ import ( "fmt" "io" + "github.com/golang/protobuf/proto" "github.com/jordanorelli/hyperstone/dota" ) @@ -49,6 +50,16 @@ func (p *parser) run() error { if err := msg.check(p.dumpPackets); err != nil { fmt.Printf("error: %v\n", err) } + default: + m := cmdFactory.BuildMessage(int(msg.cmd)) + if m != nil { + err := proto.Unmarshal(msg.body, m) + if err != nil { + fmt.Printf("cmd unmarshal error: %v\n", err) + } else { + fmt.Println(m) + } + } } } }