summaryrefslogtreecommitdiff
path: root/protocol/messages.go
diff options
context:
space:
mode:
Diffstat (limited to 'protocol/messages.go')
-rw-r--r--protocol/messages.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/protocol/messages.go b/protocol/messages.go
new file mode 100644
index 0000000..d8f5697
--- /dev/null
+++ b/protocol/messages.go
@@ -0,0 +1,29 @@
+package protocol
+
+import (
+ "encoding/json"
+ "time"
+)
+
+type TimeStamp time.Time
+
+func (t *TimeStamp) UnmarshalJSON(data []byte) error {
+ var ts int64
+ err := json.Unmarshal(data, &ts)
+ if err != nil {
+ return err
+ }
+ *t = TimeStamp(time.UnixMilli(ts))
+ return nil
+}
+
+func (t TimeStamp) MarshalJSON() ([]byte, error) {
+ return json.Marshal(time.Time(t).UnixMilli())
+}
+
+type Observation struct {
+ Time TimeStamp `json:"time"`
+ Target Target `json:"target"`
+ Online bool `json:"online"`
+ Latency uint32 `json:"latency"`
+}