gateway

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedProtocol = errors.New("unsupported protocol")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr         string
	Protocol     string // websocket or tcp
	Path         string // URL path for websocket protocol
	ConWriteSize int
	KeyFile      string
	CertFile     string
}

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config, newUser func() User) *Gate

func (*Gate) AuthorizedUser

func (gate *Gate) AuthorizedUser(user User)

func (*Gate) Broadcast

func (gate *Gate) Broadcast(receivers []int64, packet netutil.Packet)

func (*Gate) ForEachUser

func (gate *Gate) ForEachUser(visitor UserVisitor) (_break bool)

func (*Gate) GetUser

func (gate *Gate) GetUser(uid int64) (User, bool)

func (*Gate) RemoveUser

func (gate *Gate) RemoveUser(uid int64)

func (*Gate) Send

func (gate *Gate) Send(user User, packet netutil.Packet)

func (*Gate) Shutdown

func (gate *Gate) Shutdown(wg *sync.WaitGroup)

func (*Gate) Startup

func (gate *Gate) Startup(async bool) error

func (*Gate) UserCount

func (gate *Gate) UserCount() int

type User

type User interface {
	Id() int64
	GetSession() netutil.Session
	SetSession(netutil.Session)
	Authorized() bool
	SetAuthorized(bool)
	LastUnauthorizedTime() int64
	OnRecv([]byte)
	OnNewSession()
	OnQuitSession()
}

type UserVisitor

type UserVisitor func(User) (_break bool)

Jump to

Keyboard shortcuts

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