diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/data.go | 6 | ||||
| -rw-r--r-- | core/payload.go | 49 |
2 files changed, 55 insertions, 0 deletions
diff --git a/core/data.go b/core/data.go index 6871a89..4705c75 100644 --- a/core/data.go +++ b/core/data.go @@ -25,6 +25,8 @@ const ( PayloadServerAuth = 0x06 PayloadUsermode = 0x07 PayloadHistory = 0x08 + PayloadList = 0x09 + PayloadListItem = 0x10 PayloadTest = 0xFF ) @@ -146,6 +148,10 @@ func Decode(buf io.Reader) (any, error) { return DecodeUsermode(buf) case PayloadHistory: return DecodeHistory(buf) + case PayloadList: + return DecodeList(buf) + case PayloadListItem: + return DecodeListItem(buf) case PayloadTest: return DecodeTest(buf) default: diff --git a/core/payload.go b/core/payload.go index be9d844..aad21ee 100644 --- a/core/payload.go +++ b/core/payload.go @@ -226,6 +226,55 @@ func DecodeHistory(buf io.Reader) (History, error) { return h, nil } +type List struct { + Count int64 + Offset int64 +} + +func (l List) Wrap() (PayloadType, []any) { + return PayloadList, []any{ + l.Count, + l.Offset, + } +} + +func DecodeList(buf io.Reader) (List, error) { + var l List + + err := decodeNumeric(buf, &l.Count) + if err != nil { + return l, err + } + + err = decodeNumeric(buf, &l.Offset) + if err != nil { + return l, err + } + + return l, nil +} + +type ListItem struct { + Address string +} + +func (l ListItem) Wrap() (PayloadType, []any) { + return PayloadListItem, []any{ + l.Address, + } +} + +func DecodeListItem(buf io.Reader) (ListItem, error) { + var l ListItem + + err := decodeString(buf, &l.Address) + if err != nil { + return l, err + } + + return l, nil +} + type Test struct { Num1 uint8 Time1 time.Time |
