mux

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageMethodData = iota
	MessageMethodDial
)

Variables

View Source
var ErrConnClosed = errors.New("mux conn closed")

Functions

This section is empty.

Types

type Conn

type Conn struct {
	ID uint32
	// contains filtered or unexported fields
}

func (*Conn) Close added in v0.15.1

func (conn *Conn) Close() (err error)

func (*Conn) HandleMessage

func (conn *Conn) HandleMessage(m *Message) (err error)

func (*Conn) Read

func (conn *Conn) Read(p []byte) (n int, err error)

func (*Conn) Run

func (conn *Conn) Run(c *net.TCPConn)

func (*Conn) SendMessageID

func (conn *Conn) SendMessageID() (id uint32)

func (*Conn) Write

func (conn *Conn) Write(p []byte) (n int, err error)

type Group

type Group struct {
	MuxWSs []*MuxWebSocket
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup(client bool) (group *Group)

true: client group false: server group

func (*Group) AddConn added in v0.15.1

func (group *Group) AddConn(conn *Conn)

func (*Group) AddMuxWS

func (group *Group) AddMuxWS(muxWS *MuxWebSocket) (err error)

func (*Group) DeleteConn added in v0.15.1

func (group *Group) DeleteConn(id uint32)

func (*Group) GetConn added in v0.15.1

func (group *Group) GetConn(id uint32) (conn *Conn)

func (*Group) Handle

func (group *Group) Handle(m *Message)

func (*Group) Listen

func (group *Group) Listen(muxWS *MuxWebSocket)

func (*Group) NewMuxConn

func (group *Group) NewMuxConn(host string) (conn *Conn, err error)

NewMuxConn creates a new mux connection for client

func (*Group) NextConnID added in v0.15.1

func (group *Group) NextConnID() (id uint32)

func (*Group) Send

func (group *Group) Send(m *Message) (err error)

func (*Group) ServerHandleMessage

func (group *Group) ServerHandleMessage(m *Message) (err error)

ServerHandleMessage is a server group function

type Message

type Message struct {
	Method    uint8
	ConnID    uint32
	MessageID uint32
	Length    uint32
	Data      []byte
	// contains filtered or unexported fields
}

MessageHeadLength = 13

func LoadMessage

func LoadMessage(h []byte) (m *Message)

func (*Message) Read

func (m *Message) Read(p []byte) (n int, err error)

type MuxWebSocket

type MuxWebSocket struct {
	*core.WebSocket
	// contains filtered or unexported fields
}

func NewMuxWebSocket

func NewMuxWebSocket(ws *core.WebSocket) (muxWS *MuxWebSocket)

func (*MuxWebSocket) Close added in v0.15.1

func (muxWS *MuxWebSocket) Close() (err error)

func (*MuxWebSocket) Receive

func (muxWS *MuxWebSocket) Receive() (m *Message, err error)

func (*MuxWebSocket) Send

func (muxWS *MuxWebSocket) Send(m *Message) (err error)

Jump to

Keyboard shortcuts

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