gossip/pkg/protocol/types.go
2025-12-07 21:17:52 -05:00

28 lines
862 B
Go

package protocol
// MessageType ensures we only use valid protocol commands
type MessageType string
const (
// TypeLogin: Client -> Server (Handshake with Public Key)
TypeLogin MessageType = "login"
// TypeIdentity: Server -> Client (Here is your Account Number)
TypeIdentity MessageType = "identity"
// TypeLookup: Client -> Server (Who owns Account #10050?)
TypeLookup MessageType = "lookup"
// TypeLookupResponse: Server -> Client (Here is the Public Key for #10050)
TypeLookupResponse MessageType = "lookup_response"
// TypeMsg: Client -> Server -> Client (Encrypted Payload)
TypeMsg MessageType = "msg"
)
type Message struct {
Type MessageType `json:"type"`
Sender string `json:"sender"` // Hex Public Key
Target string `json:"target"` // Hex Public Key (msg) or Account # (lookup)
Content string `json:"content"`
}