netio

package
v0.0.0-...-769df87 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CEConnected
	CERecv
	CEDisconnected
)

Variables

This section is empty.

Functions

func AcceptClient

func AcceptClient(listener net.Listener, acceptFn AcceptClientFn) error

AcceptClient -

Types

type AcceptClientFn

type AcceptClientFn func(conn net.Conn) (IConn, error)

AcceptClientFn return a IConn from a net.Conn Return error if do not accept the connection

type AcceptInterceptorFn

type AcceptInterceptorFn func(conn net.Conn) error

AcceptInterceptorFn -

type Conn

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

func NewConn

func NewConn(conn net.Conn,
	outQ chan *ConnEvent,
	options *ConnOptions,
	recvCipher cipher.ICipher,
	sendCipher cipher.ICipher) *Conn

func (*Conn) Close

func (c *Conn) Close()

Close -

func (*Conn) GetInt

func (c *Conn) GetInt(k string) int

func (*Conn) GetRecvCipher

func (c *Conn) GetRecvCipher() cipher.ICipher

GetRecvCipher -

func (*Conn) GetRemoteAddress

func (c *Conn) GetRemoteAddress() string

GetRemoteAddress -

func (*Conn) GetSendCipher

func (c *Conn) GetSendCipher() cipher.ICipher

GetSendCipher -

func (*Conn) GetString

func (c *Conn) GetString(k string) string

func (*Conn) Run

func (c *Conn) Run(connectfn FnConnected, disconnectfn FnDisconnected, recvfn FnRecv)

Run -

func (*Conn) Send

func (c *Conn) Send(p maplepacket.Packet)

func (*Conn) SetInt

func (c *Conn) SetInt(k string, v int)

func (*Conn) SetString

func (c *Conn) SetString(k string, v string)

SetString -

type ConnEvent

type ConnEvent struct {
	Type   int
	Packet maplepacket.Packet
	Conn   IConn
}

type ConnOptions

type ConnOptions struct {
	HeaderSize int
}

type FnConnected

type FnConnected func(IConn, chan<- *ConnEvent)

type FnDisconnected

type FnDisconnected func(IConn, chan<- *ConnEvent)

type FnRecv

type FnRecv func(IConn, []byte, chan<- *ConnEvent)

type IConn

type IConn interface {
	Run(FnConnected, FnDisconnected, FnRecv)
	Send(maplepacket.Packet)
	Close()

	GetInt(string) int
	SetInt(string, int)

	GetString(string) string
	SetString(string, string)

	GetRecvCipher() cipher.ICipher
	GetSendCipher() cipher.ICipher

	GetRemoteAddress() string
}

Jump to

Keyboard shortcuts

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