site

package
v0.0.0-...-4ede3f3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(next http.Handler) http.Handler

func FromID

func FromID(m *hub.Msg) int64

func IsUserSess

func IsUserSess(s *ses.Session) bool

func RawMsg

func RawMsg(subj string, data interface{}) *hub.Msg

func SetupSess

func SetupSess(db *buntdb.DB, cookieName string, secure bool) (*ses.Manager, error)

Types

type Auth

type Auth struct {
	Man   *ses.Manager
	Store *BuntUserStore
}

func (*Auth) Login

func (a *Auth) Login(w http.ResponseWriter, r *http.Request)

func (*Auth) Logout

func (a *Auth) Logout(w http.ResponseWriter, r *http.Request)

type BuntSessStore

type BuntSessStore struct {
	*buntdb.DB
}

func (*BuntSessStore) Delete

func (s *BuntSessStore) Delete(td string) error

func (*BuntSessStore) Get

func (s *BuntSessStore) Get(td string) (ses.Data, error)

func (*BuntSessStore) New

func (s *BuntSessStore) New() (_ ses.Data, err error)

func (*BuntSessStore) Save

func (s *BuntSessStore) Save(d ses.Data, isnew bool) error

type BuntUserStore

type BuntUserStore struct {
	*buntdb.DB
}

func (*BuntUserStore) Get

func (s *BuntUserStore) Get(name string) (res UserData, err error)

func (*BuntUserStore) Save

func (s *BuntUserStore) Save(data UserData) error

type ChatData

type ChatData struct {
	Room  string     `json:"room"`
	Msgs  []ChatMsg  `json:"msgs"`
	Infos []UserInfo `json:"infos"`
}

type ChatMsg

type ChatMsg struct {
	User string    `json:"user"`
	Time time.Time `json:"time"`
	Msg  string    `json:"msg"`
}

type ChatRoom

type ChatRoom struct {
	ChatData
	Users map[int64]*User
	Conns
}

func NewChat

func NewChat(name string) *ChatRoom

func (*ChatRoom) Chat

func (c *ChatRoom) Chat(m *hub.Msg)

func (*ChatRoom) Enter

func (c *ChatRoom) Enter(m *hub.Msg)

func (*ChatRoom) Exit

func (c *ChatRoom) Exit(m *hub.Msg)

func (*ChatRoom) Name

func (c *ChatRoom) Name() string

func (*ChatRoom) Route

func (c *ChatRoom) Route(m *hub.Msg)

type Conns

type Conns []hub.Conn

func (Conns) Bcast

func (subs Conns) Bcast(m *hub.Msg, except int64)

func (Conns) Sub

func (subs Conns) Sub(cc hub.Conn) Conns

func (Conns) Unsub

func (subs Conns) Unsub(id int64) Conns

type EnterMsg

type EnterMsg struct {
	Room string      `json:"room"`
	User User        `json:"-"`
	Data interface{} `json:"data,omitempty"`
}

type Room

type Room interface {
	Name() string
	hub.Router
}

type SecureCodec

type SecureCodec struct {
	*securecookie.SecureCookie
	// contains filtered or unexported fields
}

func (*SecureCodec) DecodeToken

func (c *SecureCodec) DecodeToken(tok string) (td string, err error)

func (*SecureCodec) EncodeToken

func (c *SecureCodec) EncodeToken(td string) (tok string, err error)

type Sess

type Sess struct {
	Token string `json:"token"`
	Name  string `json:"name"`
	Admin bool   `json:"admin,omitempty"`
}

func (*Sess) ID

func (s *Sess) ID() string

func (*Sess) Tok

func (s *Sess) Tok() string

func (*Sess) User

func (s *Sess) User() string

type Site

type Site struct {
	*hub.Hub
	// contains filtered or unexported fields
}

func NewSite

func NewSite(rooms ...Room) *Site

func (*Site) Route

func (s *Site) Route(m *hub.Msg)

type User

type User struct {
	hub.Conn
	Name   string
	Admin  bool
	Room   Room
	Signon time.Time
}

type UserData

type UserData struct {
	Name    string
	Pass    string
	Admin   bool
	Created time.Time
	Last    time.Time
}

type UserInfo

type UserInfo struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Admin bool   `json:"admin,omitempty"`
}

Jump to

Keyboard shortcuts

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