package pusher

import "encoding/json"

// Client → Server message types
const (
	TypeSubscribe   = "subscribe"
	TypeUnsubscribe = "unsubscribe"
	TypeMessage     = "message"
)

// Server → Client message types
const (
	TypeSubscribed = "subscribed"
	TypeJoin       = "join"
	TypeLeave      = "leave"
	// TypeMessage is reused for server → client messages
	TypeError = "error"
)

type ClientMessage struct {
	Type    string          `json:"type"`
	Channel string          `json:"channel,omitempty"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

type ServerMessage struct {
	Type     string          `json:"type"`
	Channel  string          `json:"channel,omitempty"`
	HumanID  string          `json:"humanId,omitempty"`
	Presence []string        `json:"presence,omitempty"`
	Payload  json.RawMessage `json:"payload,omitempty"`
	Message  string          `json:"message,omitempty"`
}
