chat

package
v0.0.0-...-7b9808e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PriorityHigh = "primary"
	PriorityLow  = "muted"
)

Variables

View Source
var (
	DefaultActions = []Action{
		{
			Name:        "help",
			Description: "Show help information",
			Invoke:      showHelp,
		},
		{
			Name:        "users",
			Description: "List users in channel",
			Invoke:      listUsers,
		},
		{
			Name:        "channels",
			Description: "List channels on server",
			Invoke:      listChannels,
		},
	}
)

Functions

func Capitalize

func Capitalize(s ...string) []string

Types

type Action

type Action struct {
	Invoke            Handler
	Name, Description string
}

func NewAction

func NewAction(name, description string, handler Handler) Action

type Channel

type Channel struct {
	Name string
	// contains filtered or unexported fields
}

func NewChannel

func NewChannel(name string, host *Server) *Channel

func (*Channel) Join

func (c *Channel) Join(u *User)

func (*Channel) Leave

func (c *Channel) Leave(u *User)

func (*Channel) List

func (c *Channel) List() []*User

func (*Channel) Publish

func (c *Channel) Publish(msg Message)

type Handler

type Handler func(*Server, *Channel, *User, string) error

type Message

type Message struct {
	Sender   string `json:"sender"`
	Data     string `json:"data"`
	Priority string `json:"priority"`
	Channel  string `json:"channel"`
	Media    string `json:"media"`
}

type Option

type Option func(s *Server)

func WithAction

func WithAction(action Action) Option

func WithChannels

func WithChannels(names ...string) Option

func WithMOTD

func WithMOTD(motd string) Option

func WithMainChannel

func WithMainChannel(name string) Option

func WithName

func WithName(name string) Option

func WithTextInterval

func WithTextInterval(interval time.Duration) Option

func WithTextLimit

func WithTextLimit(limit int) Option

type Server

type Server struct {
	Name string
	// contains filtered or unexported fields
}

func New

func New(options ...Option) *Server

func (*Server) Accept

func (s *Server) Accept(conn *websocket.Conn)

func (*Server) AddAction

func (s *Server) AddAction(action Action)

func (*Server) AddChannel

func (s *Server) AddChannel(channel *Channel)

func (*Server) Connect

func (s *Server) Connect(broker string) error

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) List

func (s *Server) List() []*User

func (*Server) ListActions

func (s *Server) ListActions() []Action

func (*Server) ListChannels

func (s *Server) ListChannels() []*Channel

type User

type User struct {
	Name string
	// contains filtered or unexported fields
}

func NewUser

func NewUser(conn *websocket.Conn, host *Server) *User

func (*User) Send

func (user *User) Send(msg Message) error

func (*User) Watch

func (user *User) Watch()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL