Documentation
¶
Overview ¶
Package campfire provides the campfire service to webmesh clients.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) ID() string
- func (c *Client) Join(ctx context.Context, name string) error
- func (c *Client) Leave(ctx context.Context, name string) error
- func (c *Client) List(ctx context.Context, name string) ([]string, error)
- func (c *Client) Messages() <-chan Message
- func (c *Client) Send(ctx context.Context, name, to, msg string) error
- type Message
- type MessageStream
- type MessageType
- type Options
- type RoomManager
- type Server
Constants ¶
View Source
const ( // CampFirePrefix is the prefix for campfire service paths. CampFirePrefix = "/campfire" // RoomsPrefix is the prefix for campfire rooms. RoomsPrefix = CampFirePrefix + "/rooms" )
View Source
const ( CampfireEnabledEnvVar = "SERVICES_CAMPFIRE_ENABLED" CampfireListenUDPEnvVar = "SERVICES_CAMPFIRE_LISTEN_UDP" )
View Source
const DefaultListenUDP = ":4095"
DefaultListenUDP is the default UDP address to listen on.
Variables ¶
View Source
var EOF = io.EOF
EOF is an EOF error.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *MessageStream // contains filtered or unexported fields }
Client is the campfire client.
func NewClientWithID ¶
NewClientWithID returns a new campfire client with the given id.
type Message ¶
type Message struct { // Type is the message type. Type MessageType // Room is the room. Room string // From is the sender. From string // To is the recipient. To string // Body is the message body. Body string }
Message is a campfire message.
func ParseMessage ¶
ParseMessage parses a message from the wire form.
type MessageStream ¶
func NewMessageStream ¶
func NewMessageStream(c net.Conn) *MessageStream
func (*MessageStream) RecvMessage ¶
func (m *MessageStream) RecvMessage() (Message, error)
func (*MessageStream) SendMessage ¶
func (m *MessageStream) SendMessage(msg Message) error
type MessageType ¶
type MessageType int
MessageType is a message type.
const ( // MessageTypeUnknown is an unknown message type. MessageTypeUnknown MessageType = iota // MessageTypeJoin is a join message type. MessageTypeJoin // MessageTypeLeave is a leave message type. MessageTypeLeave // MessageTypeList is a list message type. MessageTypeList // MessageTypeMessage is a message message type. MessageTypeMessage // MessageTypeMember is a member message type. // This is a server-only message type. MessageTypeMember // MessageTypeACK is an ACK message type. // This is a server-only message type. MessageTypeACK // MessageTypeError is an error message type. // This is a server-only message type. MessageTypeError )
type Options ¶
type Options struct { // Enabled is whether the campfire service is enabled. Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty" toml:"enabled,omitempty" mapstructure:"enabled,omitempty"` // ListenUDP is the UDP address to listen on. ListenUDP string `json:"listen-udp,omitempty" yaml:"listen-udp,omitempty" toml:"listen-udp,omitempty" mapstructure:"listen-udp,omitempty"` }
Options are options for the campfire service.
type RoomManager ¶
type RoomManager struct {
// contains filtered or unexported fields
}
RoomManager is the room manager.
func NewRoomManager ¶
func NewRoomManager(mesh meshdb.Store, c net.PacketConn) (*RoomManager, error)
NewRoomManager returns a new room manager.
func (*RoomManager) HandleMessage ¶
func (r *RoomManager) HandleMessage(srcaddr net.Addr, msg *Message)
HandleMessage handles a campfire message.
Click to show internal directories.
Click to hide internal directories.