oknet

package
v0.0.0-...-cdc279e Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

README

useage



 wknet.Serve("tcp://127.0.0.1:1999",handler,opts...)

event

OnConnect(c *wknet.Conn)

OnClose(c *wknet.Conn)

OnData(c *wknet.Conn)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedOp occurs when calling some methods that has not been implemented yet.
	ErrUnsupportedOp = errors.New("unsupported operation")
)

Functions

func GetMaxOpenFiles

func GetMaxOpenFiles() int

Types

type Acceptor

type Acceptor struct {
	oklog.Log
	// contains filtered or unexported fields
}

func NewAcceptor

func NewAcceptor(eg *Engine) *Acceptor

func (*Acceptor) Start

func (a *Acceptor) Start() error

func (*Acceptor) Stop

func (a *Acceptor) Stop() error

type Buffer

type Buffer interface {
	// IsEmpty returns true if the buffer is empty.
	IsEmpty() bool
	// Write writes the data to the buffer.
	Write(data []byte) (int, error)
	// Read reads the data from the buffer.
	Read(data []byte) (int, error)
	// BoundBufferSize returns the bound buffer size.
	BoundBufferSize() int
	// Peek returns the data from the buffer without removing it.
	Peek(n int) (head []byte, tail []byte)
	PeekBytes(p []byte) int
	// Discard discards the data from the buffer.
	Discard(n int) (int, error)
	// Release releases the buffer.
	Release() error
}

type Conn

type Conn interface {
	// ID returns the connection id.
	ID() int64
	// SetID sets the connection id.
	SetID(id int64)
	// UID returns the user uid.
	UID() string
	// SetUID sets the user uid.
	SetUID(uid string)
	DeviceLevel() uint8
	SetDeviceLevel(deviceLevel uint8)
	// DeviceFlag returns the device flag.
	DeviceFlag() uint8
	// SetDeviceFlag sets the device flag.
	SetDeviceFlag(deviceFlag uint8)
	// DeviceID returns the device id.
	DeviceID() string
	// SetValue sets the value associated with key to value.
	SetValue(key string, value interface{})
	// Value returns the value associated with key.
	Value(key string) interface{}
	// SetDeviceID sets the device id.
	SetDeviceID(deviceID string)
	// Flush flushes the data to the connection.
	Flush() error
	// Read reads the data from the connection.
	Read(buf []byte) (int, error)
	// Peek peeks the data from the connection.
	Peek(n int) ([]byte, error)
	// Discard discards the data from the connection.
	Discard(n int) (int, error)
	// Write writes the data to the connection. TODO: Locking is required when calling write externally
	Write(b []byte) (int, error)
	// WriteToOutboundBuffer writes the data to the outbound buffer.  Thread safety
	WriteToOutboundBuffer(b []byte) (int, error)
	// Wake wakes up the connection write.
	WakeWrite() error
	// Fd returns the file descriptor of the connection.
	Fd() NetFd
	// IsClosed returns true if the connection is closed.
	IsClosed() bool
	// Close closes the connection.
	Close() error
	// RemoteAddr returns the remote network address.
	RemoteAddr() net.Addr
	// LocalAddr returns the local network address.
	LocalAddr() net.Addr
	// ReactorSub returns the reactor sub.
	ReactorSub() *ReactorSub
	// ReadToInboundBuffer read data from connection and  write to inbound buffer
	ReadToInboundBuffer() (int, error)
	SetContext(ctx interface{})
	Context() interface{}
	// IsAuthed returns true if the connection is authed.
	IsAuthed() bool
	// SetAuthed sets the connection is authed.
	SetAuthed(authed bool)
	// ProtoVersion get message proto version
	ProtoVersion() int
	// SetProtoVersion sets message proto version
	SetProtoVersion(version int)
	// LastActivity returns the last activity time.
	LastActivity() time.Time
	// Uptime returns the connection uptime.
	Uptime() time.Time
	// SetMaxIdle sets the connection max idle time.
	// If the connection is idle for more than the specified duration, it will be closed.
	SetMaxIdle(duration time.Duration)

	InboundBuffer() InboundBuffer
	OutboundBuffer() OutboundBuffer

	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error

	// ConnStats returns the connection stats.
	ConnStats() *ConnStats
}

func CreateConn

func CreateConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, reactorSub *ReactorSub) (Conn, error)

func CreateWSConn

func CreateWSConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, reactorSub *ReactorSub) (Conn, error)

func CreateWSSConn

func CreateWSSConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, reactorSub *ReactorSub) (Conn, error)

type ConnStats

type ConnStats struct {
	InMsgs   *atomic.Int64 // recv msg count
	OutMsgs  *atomic.Int64
	InBytes  *atomic.Int64
	OutBytes *atomic.Int64
}

func NewConnStats

func NewConnStats() *ConnStats

type DefaultConn

type DefaultConn struct {
	oklog.Log
	// contains filtered or unexported fields
}

func GetDefaultConn

func GetDefaultConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, reactorSub *ReactorSub) *DefaultConn

func (*DefaultConn) Close

func (d *DefaultConn) Close() error

func (*DefaultConn) ConnStats

func (d *DefaultConn) ConnStats() *ConnStats

func (*DefaultConn) Context

func (d *DefaultConn) Context() interface{}

func (*DefaultConn) DeviceFlag

func (d *DefaultConn) DeviceFlag() uint8

func (*DefaultConn) DeviceID

func (d *DefaultConn) DeviceID() string

func (*DefaultConn) DeviceLevel

func (d *DefaultConn) DeviceLevel() uint8

func (*DefaultConn) Discard

func (d *DefaultConn) Discard(n int) (int, error)

func (*DefaultConn) Fd

func (d *DefaultConn) Fd() NetFd

func (*DefaultConn) Flush

func (d *DefaultConn) Flush() error

func (*DefaultConn) ID

func (d *DefaultConn) ID() int64

func (*DefaultConn) InboundBuffer

func (d *DefaultConn) InboundBuffer() InboundBuffer

func (*DefaultConn) IsAuthed

func (d *DefaultConn) IsAuthed() bool

func (*DefaultConn) IsClosed

func (d *DefaultConn) IsClosed() bool

func (*DefaultConn) KeepLastActivity

func (d *DefaultConn) KeepLastActivity()

func (*DefaultConn) LastActivity

func (d *DefaultConn) LastActivity() time.Time

func (*DefaultConn) LocalAddr

func (d *DefaultConn) LocalAddr() net.Addr

func (*DefaultConn) OutboundBuffer

func (d *DefaultConn) OutboundBuffer() OutboundBuffer

func (*DefaultConn) Peek

func (d *DefaultConn) Peek(n int) ([]byte, error)

func (*DefaultConn) ProtoVersion

func (d *DefaultConn) ProtoVersion() int

func (*DefaultConn) ReactorSub

func (d *DefaultConn) ReactorSub() *ReactorSub

func (*DefaultConn) Read

func (d *DefaultConn) Read(buf []byte) (int, error)

func (*DefaultConn) ReadToInboundBuffer

func (d *DefaultConn) ReadToInboundBuffer() (int, error)

func (*DefaultConn) RemoteAddr

func (d *DefaultConn) RemoteAddr() net.Addr

func (*DefaultConn) SetAuthed

func (d *DefaultConn) SetAuthed(authed bool)

func (*DefaultConn) SetContext

func (d *DefaultConn) SetContext(ctx interface{})

func (*DefaultConn) SetDeadline

func (d *DefaultConn) SetDeadline(t time.Time) error

func (*DefaultConn) SetDeviceFlag

func (d *DefaultConn) SetDeviceFlag(deviceFlag uint8)

func (*DefaultConn) SetDeviceID

func (d *DefaultConn) SetDeviceID(deviceID string)

func (*DefaultConn) SetDeviceLevel

func (d *DefaultConn) SetDeviceLevel(deviceLevel uint8)

func (*DefaultConn) SetID

func (d *DefaultConn) SetID(id int64)

func (*DefaultConn) SetMaxIdle

func (d *DefaultConn) SetMaxIdle(maxIdle time.Duration)

func (*DefaultConn) SetProtoVersion

func (d *DefaultConn) SetProtoVersion(version int)

func (*DefaultConn) SetReadDeadline

func (d *DefaultConn) SetReadDeadline(t time.Time) error

func (*DefaultConn) SetUID

func (d *DefaultConn) SetUID(uid string)

func (*DefaultConn) SetValue

func (d *DefaultConn) SetValue(key string, value interface{})

func (*DefaultConn) SetWriteDeadline

func (d *DefaultConn) SetWriteDeadline(t time.Time) error

func (*DefaultConn) String

func (d *DefaultConn) String() string

func (*DefaultConn) UID

func (d *DefaultConn) UID() string

func (*DefaultConn) Uptime

func (d *DefaultConn) Uptime() time.Time

func (*DefaultConn) Value

func (d *DefaultConn) Value(key string) interface{}

func (*DefaultConn) WakeWrite

func (d *DefaultConn) WakeWrite() error

func (*DefaultConn) Write

func (d *DefaultConn) Write(b []byte) (int, error)

func (*DefaultConn) WriteDirect

func (d *DefaultConn) WriteDirect(head, tail []byte) (int, error)

func (*DefaultConn) WriteToOutboundBuffer

func (d *DefaultConn) WriteToOutboundBuffer(b []byte) (int, error)

write to outbound buffer

type DefualtBuffer

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

func NewDefaultBuffer

func NewDefaultBuffer() *DefualtBuffer

func (*DefualtBuffer) BoundBufferSize

func (d *DefualtBuffer) BoundBufferSize() int

func (*DefualtBuffer) Discard

func (d *DefualtBuffer) Discard(n int) (int, error)

func (*DefualtBuffer) IsEmpty

func (d *DefualtBuffer) IsEmpty() bool

func (*DefualtBuffer) Peek

func (d *DefualtBuffer) Peek(n int) (head []byte, tail []byte)

func (*DefualtBuffer) PeekBytes

func (d *DefualtBuffer) PeekBytes(p []byte) int

func (*DefualtBuffer) Read

func (d *DefualtBuffer) Read(data []byte) (int, error)

func (*DefualtBuffer) Release

func (d *DefualtBuffer) Release() error

func (*DefualtBuffer) Write

func (d *DefualtBuffer) Write(data []byte) (int, error)

type Engine

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

func NewEngine

func NewEngine(opts ...Option) *Engine

func (*Engine) AddConn

func (e *Engine) AddConn(conn Conn)

func (*Engine) ConnCount

func (e *Engine) ConnCount() int

func (*Engine) GenClientID

func (e *Engine) GenClientID() int64

func (*Engine) GetAllConn

func (e *Engine) GetAllConn() []Conn

func (*Engine) GetConn

func (e *Engine) GetConn(fd int) Conn

func (*Engine) OnClose

func (e *Engine) OnClose(onClose OnClose)

func (*Engine) OnConnect

func (e *Engine) OnConnect(onConnect OnConnect)

func (*Engine) OnData

func (e *Engine) OnData(onData OnData)

func (*Engine) OnNewConn

func (e *Engine) OnNewConn(onNewConn OnNewConn)

func (*Engine) OnNewInboundConn

func (e *Engine) OnNewInboundConn(onNewInboundConn OnNewInboundConn)

func (*Engine) OnNewOutboundConn

func (e *Engine) OnNewOutboundConn(onNewOutboundConn OnNewOutboundConn)

func (*Engine) RemoveConn

func (e *Engine) RemoveConn(conn Conn)

func (*Engine) Schedule

func (e *Engine) Schedule(interval time.Duration, f func()) *timingwheel.Timer

Schedule 延迟任务

func (*Engine) Start

func (e *Engine) Start() error

func (*Engine) Stop

func (e *Engine) Stop() error

func (*Engine) TCPRealListenAddr

func (e *Engine) TCPRealListenAddr() net.Addr

func (*Engine) WSRealListenAddr

func (e *Engine) WSRealListenAddr() net.Addr

func (*Engine) WSSRealListenAddr

func (e *Engine) WSSRealListenAddr() net.Addr

type EventHandler

type EventHandler struct {
	// OnConnect is called when a new connection is established.
	OnConnect func(conn Conn) error
	// OnData is called when a data is received.
	OnData func(conn Conn) error
	// OnClose is called when a connection is closed.
	OnClose func(conn Conn)
	// OnNewConn is called when a new connection is established.
	OnNewConn OnNewConn
	// OnNewWSConn is called when a new websocket connection is established.
	OnNewWSConn  OnNewConn
	OnNewWSSConn OnNewConn
	// OnNewInboundConn is called when need create a new inbound buffer.
	OnNewInboundConn OnNewInboundConn
	// OnNewOutboundConn is called when need create a new outbound buffer.
	OnNewOutboundConn OnNewOutboundConn
}

func NewEventHandler

func NewEventHandler() *EventHandler

type IWSConn

type IWSConn interface {
	WriteServerBinary(data []byte) error
}

type InboundBuffer

type InboundBuffer interface {
	Buffer
}

type NetFd

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

func (NetFd) Close

func (n NetFd) Close() error

func (NetFd) Fd

func (n NetFd) Fd() int

func (NetFd) Read

func (n NetFd) Read(b []byte) (int, error)

func (NetFd) Write

func (n NetFd) Write(b []byte) (int, error)

type OnClose

type OnClose func(conn Conn)

type OnConnect

type OnConnect func(conn Conn) error

type OnData

type OnData func(conn Conn) error

type OnNewConn

type OnNewConn func(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, reactorSub *ReactorSub) (Conn, error)

type OnNewInboundConn

type OnNewInboundConn func(conn Conn, eg *Engine) InboundBuffer

type OnNewOutboundConn

type OnNewOutboundConn func(conn Conn, eg *Engine) OutboundBuffer

type Option

type Option func(opts *Options)

func WithAddr

func WithAddr(v string) Option

WithAddr set listen addr

func WithMaxOpenFiles

func WithMaxOpenFiles(v int) Option

WithMaxOpenFiles the maximum number of open files that the server can

func WithSocketRecvBuffer

func WithSocketRecvBuffer(recvBuf int) Option

WithSocketRecvBuffer sets the maximum socket receive buffer in bytes.

func WithSocketSendBuffer

func WithSocketSendBuffer(sendBuf int) Option

WithSocketSendBuffer sets the maximum socket send buffer in bytes.

func WithSubReactorNum

func WithSubReactorNum(v int) Option

WithSubReactorNum set sub reactor number

func WithTCPKeepAlive

func WithTCPKeepAlive(v time.Duration) Option

WithTCPKeepAlive sets up a duration for (SO_KEEPALIVE) socket option.

func WithTCPTLSConfig

func WithTCPTLSConfig(v *tls.Config) Option

func WithWSAddr

func WithWSAddr(v string) Option

func WithWSSAddr

func WithWSSAddr(v string) Option

func WithWSTLSConfig

func WithWSTLSConfig(v *tls.Config) Option

type Options

type Options struct {
	// Addr is the listen addr  example: tcp://127.0.0.1:5100
	Addr string
	// TcpTlsConfig tcp tls config
	TCPTLSConfig *tls.Config
	WSTLSConfig  *tls.Config
	// WsAddr is the listen addr  example: ws://127.0.0.1:5200或 wss://127.0.0.1:5200
	WsAddr  string
	WssAddr string // wss addr
	// WSTlsConfig ws tls config
	// MaxOpenFiles is the maximum number of open files that the server can
	MaxOpenFiles int
	// SubReactorNum is sub reactor numver it's set to runtime.NumCPU()  by default
	SubReactorNum int
	// OnCreateConn allow custom conn
	// ReadBuffSize is the read size of the buffer each time from the connection
	ReadBufferSize int
	// MaxWriteBufferSize is the write maximum size of the buffer for each connection
	MaxWriteBufferSize int
	// MaxReadBufferSize is the read maximum size of the buffer for each connection
	MaxReadBufferSize int
	// SocketRecvBuffer sets the maximum socket receive buffer in bytes.
	SocketRecvBuffer int
	// SocketSendBuffer sets the maximum socket send buffer in bytes.
	SocketSendBuffer int
	// TCPKeepAlive sets up a duration for (SO_KEEPALIVE) socket option.
	TCPKeepAlive time.Duration
}

func NewOptions

func NewOptions() *Options

type OutboundBuffer

type OutboundBuffer interface {
	Buffer
}

type ReactorMain

type ReactorMain struct {
	oklog.Log
	// contains filtered or unexported fields
}

func NewReactorMain

func NewReactorMain(eg *Engine) *ReactorMain

func (*ReactorMain) Start

func (m *ReactorMain) Start() error

func (*ReactorMain) Stop

func (m *ReactorMain) Stop() error

type ReactorSub

type ReactorSub struct {
	oklog.Log
	ReadBuffer []byte
	// contains filtered or unexported fields
}

ReactorSub is a sub reactor.

func NewReactorSub

func NewReactorSub(eg *Engine, index int) *ReactorSub

NewReactorSub instantiates a sub reactor.

func (*ReactorSub) AddConn

func (r *ReactorSub) AddConn(conn Conn) error

AddConn adds a connection to the sub reactor.

func (*ReactorSub) AddRead

func (r *ReactorSub) AddRead(conn Conn) error

func (*ReactorSub) AddWrite

func (r *ReactorSub) AddWrite(conn Conn) error

func (*ReactorSub) CloseConn

func (r *ReactorSub) CloseConn(c Conn, er error) (rerr error)

func (*ReactorSub) ConnDec

func (r *ReactorSub) ConnDec()

func (*ReactorSub) ConnInc

func (r *ReactorSub) ConnInc()

func (*ReactorSub) DeleteFd

func (r *ReactorSub) DeleteFd(conn Conn) error

func (*ReactorSub) RemoveRead

func (r *ReactorSub) RemoveRead(conn Conn) error

func (*ReactorSub) RemoveReadAndWrite

func (r *ReactorSub) RemoveReadAndWrite(conn Conn) error

func (*ReactorSub) RemoveWrite

func (r *ReactorSub) RemoveWrite(conn Conn) error

func (*ReactorSub) Start

func (r *ReactorSub) Start() error

Start starts the sub reactor.

func (*ReactorSub) Stop

func (r *ReactorSub) Stop() error

Stop stops the sub reactor.

type RingBuffer

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

RingBuffer is the elastic wrapper of ring.Buffer.

func (*RingBuffer) Available

func (b *RingBuffer) Available() int

Available returns the length of available bytes to write.

func (*RingBuffer) Buffered

func (b *RingBuffer) Buffered() int

Buffered returns the length of available bytes to read.

func (*RingBuffer) Bytes

func (b *RingBuffer) Bytes() []byte

Bytes returns all available read bytes. It does not move the read pointer and only copy the available data.

func (*RingBuffer) Cap

func (b *RingBuffer) Cap() int

Cap returns the size of the underlying buffer.

func (*RingBuffer) Discard

func (b *RingBuffer) Discard(n int) (int, error)

Discard skips the next n bytes by advancing the read pointer.

func (*RingBuffer) Done

func (b *RingBuffer) Done()

Done checks and returns the internal ring-buffer to pool.

func (*RingBuffer) IsEmpty

func (b *RingBuffer) IsEmpty() bool

IsEmpty tells if this ring-buffer is empty.

func (*RingBuffer) IsFull

func (b *RingBuffer) IsFull() bool

IsFull tells if this ring-buffer is full.

func (*RingBuffer) Len

func (b *RingBuffer) Len() int

Len returns the length of the underlying buffer.

func (*RingBuffer) Peek

func (b *RingBuffer) Peek(n int) (head []byte, tail []byte)

Peek returns the next n bytes without advancing the read pointer, it returns all bytes when n <= 0.

func (*RingBuffer) Read

func (b *RingBuffer) Read(p []byte) (int, error)

Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more. When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.

func (*RingBuffer) ReadByte

func (b *RingBuffer) ReadByte() (byte, error)

ReadByte reads and returns the next byte from the input or ErrIsEmpty.

func (*RingBuffer) ReadFrom

func (b *RingBuffer) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom.

func (*RingBuffer) Reset

func (b *RingBuffer) Reset()

Reset the read pointer and write pointer to zero.

func (*RingBuffer) Write

func (b *RingBuffer) Write(p []byte) (int, error)

Write writes len(p) bytes from p to the underlying buf. It returns the number of bytes written from p (n == len(p) > 0) and any error encountered that caused the write to stop early. If the length of p is greater than the writable capacity of this ring-buffer, it will allocate more memory to this ring-buffer. Write must not modify the slice data, even temporarily.

func (*RingBuffer) WriteByte

func (b *RingBuffer) WriteByte(c byte) error

WriteByte writes one byte into buffer.

func (*RingBuffer) WriteString

func (b *RingBuffer) WriteString(s string) (int, error)

WriteString writes the contents of the string s to buffer, which accepts a slice of bytes.

func (*RingBuffer) WriteTo

func (b *RingBuffer) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo.

type TLSConn

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

func (*TLSConn) BuffReader

func (t *TLSConn) BuffReader(needs int) io.Reader

func (*TLSConn) BuffWriter

func (t *TLSConn) BuffWriter() io.Writer

func (*TLSConn) Close

func (t *TLSConn) Close() error

func (*TLSConn) ConnStats

func (t *TLSConn) ConnStats() *ConnStats

func (*TLSConn) Context

func (t *TLSConn) Context() interface{}

func (*TLSConn) DeviceFlag

func (t *TLSConn) DeviceFlag() uint8

func (*TLSConn) DeviceID

func (t *TLSConn) DeviceID() string

func (*TLSConn) DeviceLevel

func (t *TLSConn) DeviceLevel() uint8

func (*TLSConn) Discard

func (t *TLSConn) Discard(n int) (int, error)

func (*TLSConn) Fd

func (t *TLSConn) Fd() NetFd

func (*TLSConn) Flush

func (t *TLSConn) Flush() error

func (*TLSConn) ID

func (t *TLSConn) ID() int64

func (*TLSConn) InboundBuffer

func (t *TLSConn) InboundBuffer() InboundBuffer

func (*TLSConn) IsAuthed

func (t *TLSConn) IsAuthed() bool

func (*TLSConn) IsClosed

func (t *TLSConn) IsClosed() bool

func (*TLSConn) LastActivity

func (t *TLSConn) LastActivity() time.Time

func (*TLSConn) LocalAddr

func (t *TLSConn) LocalAddr() net.Addr

func (*TLSConn) OutboundBuffer

func (t *TLSConn) OutboundBuffer() OutboundBuffer

func (*TLSConn) Peek

func (t *TLSConn) Peek(n int) ([]byte, error)

func (*TLSConn) ProtoVersion

func (t *TLSConn) ProtoVersion() int

func (*TLSConn) ReactorSub

func (t *TLSConn) ReactorSub() *ReactorSub

func (*TLSConn) Read

func (t *TLSConn) Read(b []byte) (int, error)

func (*TLSConn) ReadToInboundBuffer

func (t *TLSConn) ReadToInboundBuffer() (int, error)

func (*TLSConn) RemoteAddr

func (t *TLSConn) RemoteAddr() net.Addr

func (*TLSConn) SetAuthed

func (t *TLSConn) SetAuthed(authed bool)

func (*TLSConn) SetContext

func (t *TLSConn) SetContext(ctx interface{})

func (*TLSConn) SetDeadline

func (t *TLSConn) SetDeadline(tim time.Time) error

func (*TLSConn) SetDeviceFlag

func (t *TLSConn) SetDeviceFlag(flag uint8)

func (*TLSConn) SetDeviceID

func (t *TLSConn) SetDeviceID(id string)

func (*TLSConn) SetDeviceLevel

func (t *TLSConn) SetDeviceLevel(level uint8)

func (*TLSConn) SetID

func (t *TLSConn) SetID(id int64)

func (*TLSConn) SetMaxIdle

func (t *TLSConn) SetMaxIdle(maxIdle time.Duration)

func (*TLSConn) SetProtoVersion

func (t *TLSConn) SetProtoVersion(version int)

func (*TLSConn) SetReadDeadline

func (t *TLSConn) SetReadDeadline(tim time.Time) error

func (*TLSConn) SetUID

func (t *TLSConn) SetUID(uid string)

func (*TLSConn) SetValue

func (t *TLSConn) SetValue(key string, value interface{})

func (*TLSConn) SetWriteDeadline

func (t *TLSConn) SetWriteDeadline(tim time.Time) error

func (*TLSConn) String

func (t *TLSConn) String() string

func (*TLSConn) UID

func (t *TLSConn) UID() string

func (*TLSConn) Uptime

func (t *TLSConn) Uptime() time.Time

func (*TLSConn) Value

func (t *TLSConn) Value(key string) interface{}

func (*TLSConn) WakeWrite

func (t *TLSConn) WakeWrite() error

func (*TLSConn) Write

func (t *TLSConn) Write(b []byte) (int, error)

func (*TLSConn) WriteToOutboundBuffer

func (t *TLSConn) WriteToOutboundBuffer(b []byte) (int, error)

type WSConn

type WSConn struct {
	*DefaultConn
	// contains filtered or unexported fields
}

func NewWSConn

func NewWSConn(d *DefaultConn) *WSConn

func (*WSConn) Close

func (w *WSConn) Close() error

func (*WSConn) DiscardFromTemp

func (w *WSConn) DiscardFromTemp(n int)

func (*WSConn) PeekFromTemp

func (w *WSConn) PeekFromTemp(n int) ([]byte, error)

func (*WSConn) ReadToInboundBuffer

func (w *WSConn) ReadToInboundBuffer() (int, error)

func (*WSConn) WriteServerBinary

func (w *WSConn) WriteServerBinary(data []byte) error

type WSSConn

type WSSConn struct {
	*TLSConn
	// contains filtered or unexported fields
}

func NewWSSConn

func NewWSSConn(tlsConn *TLSConn) *WSSConn

func (*WSSConn) Close

func (w *WSSConn) Close() error

func (*WSSConn) ReadToInboundBuffer

func (w *WSSConn) ReadToInboundBuffer() (int, error)

func (*WSSConn) WriteServerBinary

func (w *WSSConn) WriteServerBinary(data []byte) error

Directories

Path Synopsis
crypto
tls
Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446.
Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446.

Jump to

Keyboard shortcuts

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