libnet

package
v0.0.0-...-53e0952 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_BUFFER_SIZE = 4096

Variables

View Source
var (
	ErrClosed   = errors.New("Session closed")
	ErrBlocking = errors.New("Operation blocking")
)

Functions

This section is empty.

Types

type BroadcastProtocol

type BroadcastProtocol interface {
	Broadcast(msg interface{}, fetcher SessionFetcher) error
}

type BufioCodecType

type BufioCodecType struct {
	CodecType       CodecType
	ReadBufferSize  int
	WriteBufferSize int
}

func Bufio

func Bufio(codecType CodecType) *BufioCodecType

func (*BufioCodecType) NewCodec

func (codecType *BufioCodecType) NewCodec(r io.Reader, w io.Writer) Codec

type Channel

type Channel struct {

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

func NewChannel

func NewChannel() *Channel

func NewCustomChannel

func NewCustomChannel(protocol BroadcastProtocol) *Channel

func (*Channel) Broadcast

func (channel *Channel) Broadcast(msg interface{}) error

func (*Channel) Close

func (channel *Channel) Close()

func (*Channel) Exit

func (channel *Channel) Exit(session *Session) bool

func (*Channel) Fetch

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

Fetch the sessions. NOTE: Dead lock happends if invoke Exit() in fetch callback.

func (*Channel) Join

func (channel *Channel) Join(session *Session)

func (*Channel) Len

func (channel *Channel) Len() int

type Codec

type Codec interface {
	Decode(msg interface{}) error
	Encode(msg interface{}) error
}

type CodecType

type CodecType interface {
	NewCodec(r io.Reader, w io.Writer) Codec
}

func Bytes

func Bytes(spliter binary.Spliter) CodecType

func Gob

func Gob() CodecType

func Json

func Json() CodecType

func Packet

func Packet(spliter binary.Spliter, codecType CodecType) CodecType

func SelfCodec

func SelfCodec() CodecType

func String

func String(spliter binary.Spliter) CodecType

func Xml

func Xml() CodecType

type SelfDecoder

type SelfDecoder interface {
	SelfDecode(*binary.Reader) error
}

type SelfEncoder

type SelfEncoder interface {
	SelfEncode(*binary.Writer) error
}

type Server

type Server struct {

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

func NewServer

func NewServer(listener net.Listener, codecType CodecType) *Server

func Serve

func Serve(network, address string, codecType CodecType) (*Server, error)

func (*Server) Accept

func (server *Server) Accept() (*Session, error)

func (*Server) Listener

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

func (*Server) Stop

func (server *Server) Stop() bool

type Session

type Session struct {

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

func Connect

func Connect(network, address string, codecType CodecType) (*Session, error)

func ConnectTimeout

func ConnectTimeout(network, address string, timeout time.Duration, codecType CodecType) (*Session, error)

func NewSession

func NewSession(conn net.Conn, codecType CodecType) *Session

func (*Session) AddCloseCallback

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

func (*Session) AsyncSend

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

func (*Session) Close

func (session *Session) Close()

func (*Session) Conn

func (session *Session) Conn() net.Conn

func (*Session) EnableAsyncSend

func (session *Session) EnableAsyncSend(sendChanSize int)

func (*Session) Id

func (session *Session) Id() uint64

func (*Session) IsClosed

func (session *Session) IsClosed() bool

func (*Session) Receive

func (session *Session) Receive(msg interface{}) (err error)

func (*Session) RemoveCloseCallback

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

func (*Session) Send

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

type SessionFetcher

type SessionFetcher func(func(*Session))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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