Compare commits
2 Commits
69f3d4973b
...
f49c977052
Author | SHA1 | Date | |
---|---|---|---|
f49c977052 | |||
fe5f2448a1 |
@ -221,7 +221,7 @@ func (this *Protocol) unmarshalMessage(out io.Writer, message Message) error {
|
|||||||
fmt.Fprintf(out, "\t}\n")
|
fmt.Fprintf(out, "\t}\n")
|
||||||
if requiredTotal > 0 {
|
if requiredTotal > 0 {
|
||||||
fmt.Fprintf(out,
|
fmt.Fprintf(out,
|
||||||
"\tif foundRequired != %d { return hopp.ErrPairMissing }\n",
|
"\tif foundRequired != %d { return hopp.ErrTablePairMissing }\n",
|
||||||
requiredTotal)
|
requiredTotal)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "\treturn nil\n")
|
fmt.Fprintf(out, "\treturn nil\n")
|
||||||
|
12
message.go
12
message.go
@ -50,15 +50,3 @@ func (this *MessageData) UnmarshalBinary(buffer []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protocol maps methods to functions that create messages. The messages must be
|
|
||||||
// passed by reference, and the functions must return a new object every time.
|
|
||||||
type Protocol map[uint16] func() Message
|
|
||||||
|
|
||||||
// Add adds messages to the protocol. Messages with conflicting methods will
|
|
||||||
// be replaced.
|
|
||||||
func (this Protocol) Add(messages ...func() Message) {
|
|
||||||
for _, message := range messages {
|
|
||||||
this[message().Method()] = message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user