link

package
v0.0.0-...-bac99df Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SessionBlockedError = errors.New("Session Blocked")
View Source
var SessionClosedError = errors.New("Session Closed")

Functions

func Accept

func Accept(listener net.Listener) (net.Conn, error)

Types

type Channel

type Channel struct {

	// channel state
	State interface{}
	// contains filtered or unexported fields
}

func NewChannel

func NewChannel() *Channel

func (*Channel) Close

func (channel *Channel) Close()

func (*Channel) Fetch

func (channel *Channel) Fetch(callback func(*Session))

func (*Channel) FetchAndRemove

func (channel *Channel) FetchAndRemove(callback func(*Session))

func (*Channel) Get

func (channel *Channel) Get(key KEY) *Session

func (*Channel) Len

func (channel *Channel) Len() int

func (*Channel) Put

func (channel *Channel) Put(key KEY, session *Session)

func (*Channel) Remove

func (channel *Channel) Remove(key KEY) bool

type ClearSendChan

type ClearSendChan interface {
	ClearSendChan(<-chan interface{})
}

type Codec

type Codec interface {
	Receive() (interface{}, error)
	Send(interface{}) error
	Close() error
}

type Handler

type Handler interface {
	HandleSession(*Session)
}

type HandlerFunc

type HandlerFunc func(*Session)

func (HandlerFunc) HandleSession

func (f HandlerFunc) HandleSession(session *Session)

type ISessionHandler

type ISessionHandler interface {
	HandleMessage(*Session, []byte)
	HandleError(*Session, error)
	//HandleClose(*Session, int, string) error
	HandleConnect(*Session) error
	HandleDisconnect(*Session)
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

type KEY

type KEY interface{}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Dispose

func (manager *Manager) Dispose()

func (*Manager) GetSession

func (manager *Manager) GetSession(sessionID uint64) *Session

func (*Manager) NewSession

func (manager *Manager) NewSession(codec Codec, sendChanSize int) *Session

func (*Manager) SessionNum

func (manager *Manager) SessionNum() (num int)

type Protocol

type Protocol interface {
	NewCodec(rw io.ReadWriter) (Codec, error)
}

type ProtocolFunc

type ProtocolFunc func(rw io.ReadWriter) (Codec, error)

func (ProtocolFunc) NewCodec

func (pf ProtocolFunc) NewCodec(rw io.ReadWriter) (Codec, error)

type Server

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

func Listen

func Listen(address string, protocol Protocol, sendChanSize int, handler Handler) (*Server, error)

func NewServer

func NewServer(listener net.Listener, protocol Protocol, sendChanSize int, handler Handler) *Server

func (*Server) GetSession

func (server *Server) GetSession(sessionID uint64) *Session

func (*Server) Listener

func (server *Server) Listener() net.Listener

func (*Server) Serve

func (server *Server) Serve() error

func (*Server) SessionNum

func (server *Server) SessionNum() (num int)

func (*Server) Stop

func (server *Server) Stop()

type Session

type Session struct {
	State interface{}
	// contains filtered or unexported fields
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func Dial

func Dial(address string, protocol Protocol, sendChanSize int) (*Session, error)

func DialTimeout

func DialTimeout(address string, timeout time.Duration, protocol Protocol, sendChanSize int) (*Session, error)

func NewSession

func NewSession(codec Codec, sendChanSize int) *Session

func (*Session) AddCloseCallback

func (session *Session) AddCloseCallback(handler, key interface{}, callback func())

func (*Session) Close

func (session *Session) Close() error

func (*Session) Codec

func (session *Session) Codec() Codec

func (*Session) ID

func (session *Session) ID() uint64

func (*Session) IsClosed

func (session *Session) IsClosed() bool

func (*Session) Receive

func (session *Session) Receive() (interface{}, error)

func (*Session) RemoveCloseCallback

func (session *Session) RemoveCloseCallback(handler, key interface{})

func (*Session) Send

func (session *Session) Send(msg interface{}) error

type SessionHandler

type SessionHandler struct {
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func (SessionHandler) HandleConnect

func (SessionHandler) HandleConnect(*Session) error

func (SessionHandler) HandleDisconnect

func (SessionHandler) HandleDisconnect(*Session)

func (SessionHandler) HandleError

func (SessionHandler) HandleError(*Session, error)

func (SessionHandler) HandleMessage

func (SessionHandler) HandleMessage(*Session, []byte)

type SessionID

type SessionID = uint64

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Directories

Path Synopsis
benchmark
msg

Jump to

Keyboard shortcuts

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