2019-02-22 09:23:14 +00:00
|
|
|
package gun
|
|
|
|
|
2019-02-22 19:51:50 +00:00
|
|
|
import "encoding/json"
|
|
|
|
|
2019-02-22 09:23:14 +00:00
|
|
|
type Message struct {
|
2019-02-22 19:51:50 +00:00
|
|
|
Ack string `json:"@,omitempty"`
|
|
|
|
ID string `json:"#,omitempty"`
|
|
|
|
To string `json:"><,omitempty"`
|
|
|
|
Hash json.Number `json:"##,omitempty"`
|
2019-02-22 09:23:14 +00:00
|
|
|
How string `json:"how,omitempty"`
|
|
|
|
Get *MessageGetRequest `json:"get,omitempty"`
|
|
|
|
Put map[string]*Node `json:"put,omitempty"`
|
|
|
|
DAM string `json:"dam,omitempty"`
|
|
|
|
PID string `json:"pid,omitempty"`
|
|
|
|
}
|
|
|
|
|
2019-02-22 19:51:50 +00:00
|
|
|
func (m *Message) Clone() *Message {
|
|
|
|
msg := &Message{}
|
|
|
|
*msg = *m
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
2019-02-22 09:23:14 +00:00
|
|
|
type MessageGetRequest struct {
|
|
|
|
Soul string `json:"#,omitempty"`
|
|
|
|
Field string `json:".,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MessageReceived struct {
|
|
|
|
*Message
|
2019-02-22 18:40:02 +00:00
|
|
|
peer *gunPeer
|
2019-02-22 09:23:14 +00:00
|
|
|
}
|