summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/data.go3
-rw-r--r--core/payload.go41
2 files changed, 44 insertions, 0 deletions
diff --git a/core/data.go b/core/data.go
index 2a98347..4d18604 100644
--- a/core/data.go
+++ b/core/data.go
@@ -24,6 +24,7 @@ const (
PayloadMessage = 0x05
PayloadServerAuth = 0x06
PayloadUsermode = 0x07
+ PayloadHistory = 0x08
PayloadTest = 0xFF
)
@@ -143,6 +144,8 @@ func Decode(buf io.Reader) (any, error) {
return DecodeMessage(buf)
case PayloadUsermode:
return DecodeUsermode(buf)
+ case PayloadHistory:
+ return DecodeHistory(buf)
case PayloadTest:
return DecodeTest(buf)
default:
diff --git a/core/payload.go b/core/payload.go
index 3c3afa1..b54a8cd 100644
--- a/core/payload.go
+++ b/core/payload.go
@@ -185,6 +185,47 @@ func DecodeUsermode(buf io.Reader) (Usermode, error) {
return u, nil
}
+type History struct {
+ Channel string
+ Since time.Time
+ Count int64
+ Offset int64
+}
+
+func (h History) Wrap() (PayloadType, []any) {
+ return PayloadHistory, []any{
+ h.Channel,
+ h.Since,
+ h.Count,
+ h.Offset,
+ }
+}
+
+func DecodeHistory(buf io.Reader) (History, error) {
+ var h History
+ err := decodeString(buf, &h.Channel)
+ if err != nil {
+ return h, err
+ }
+
+ err = decodeTime(buf, &h.Since)
+ if err != nil {
+ return h, err
+ }
+
+ err = decodeNumeric(buf, &h.Count)
+ if err != nil {
+ return h, err
+ }
+
+ err = decodeNumeric(buf, &h.Offset)
+ if err != nil {
+ return h, err
+ }
+
+ return h, nil
+}
+
type Test struct {
Num1 uint8
Time1 time.Time