Documentation ¶
Index ¶
- Variables
- func GetMaxOpenFiles() int
- type Acceptor
- type Buffer
- type Conn
- func CreateConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, ...) (Conn, error)
- func CreateWSConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, ...) (Conn, error)
- func CreateWSSConn(id int64, connFd NetFd, localAddr, remoteAddr net.Addr, eg *Engine, ...) (Conn, error)
- type ConnStats
- type DefaultConn
- func (d *DefaultConn) Close() error
- func (d *DefaultConn) ConnStats() *ConnStats
- func (d *DefaultConn) Context() interface{}
- func (d *DefaultConn) DeviceFlag() uint8
- func (d *DefaultConn) DeviceID() string
- func (d *DefaultConn) DeviceLevel() uint8
- func (d *DefaultConn) Discard(n int) (int, error)
- func (d *DefaultConn) Fd() NetFd
- func (d *DefaultConn) Flush() error
- func (d *DefaultConn) ID() int64
- func (d *DefaultConn) InboundBuffer() InboundBuffer
- func (d *DefaultConn) IsAuthed() bool
- func (d *DefaultConn) IsClosed() bool
- func (d *DefaultConn) KeepLastActivity()
- func (d *DefaultConn) LastActivity() time.Time
- func (d *DefaultConn) LocalAddr() net.Addr
- func (d *DefaultConn) OutboundBuffer() OutboundBuffer
- func (d *DefaultConn) Peek(n int) ([]byte, error)
- func (d *DefaultConn) ProtoVersion() int
- func (d *DefaultConn) ReactorSub() *ReactorSub
- func (d *DefaultConn) Read(buf []byte) (int, error)
- func (d *DefaultConn) ReadToInboundBuffer() (int, error)
- func (d *DefaultConn) RemoteAddr() net.Addr
- func (d *DefaultConn) SetAuthed(authed bool)
- func (d *DefaultConn) SetContext(ctx interface{})
- func (d *DefaultConn) SetDeadline(t time.Time) error
- func (d *DefaultConn) SetDeviceFlag(deviceFlag uint8)
- func (d *DefaultConn) SetDeviceID(deviceID string)
- func (d *DefaultConn) SetDeviceLevel(deviceLevel uint8)
- func (d *DefaultConn) SetID(id int64)
- func (d *DefaultConn) SetMaxIdle(maxIdle time.Duration)
- func (d *DefaultConn) SetProtoVersion(version int)
- func (d *DefaultConn) SetReadDeadline(t time.Time) error
- func (d *DefaultConn) SetUID(uid string)
- func (d *DefaultConn) SetValue(key string, value interface{})
- func (d *DefaultConn) SetWriteDeadline(t time.Time) error
- func (d *DefaultConn) String() string
- func (d *DefaultConn) UID() string
- func (d *DefaultConn) Uptime() time.Time
- func (d *DefaultConn) Value(key string) interface{}
- func (d *DefaultConn) WakeWrite() error
- func (d *DefaultConn) Write(b []byte) (int, error)
- func (d *DefaultConn) WriteDirect(head, tail []byte) (int, error)
- func (d *DefaultConn) WriteToOutboundBuffer(b []byte) (int, error)
- type DefualtBuffer
- func (d *DefualtBuffer) BoundBufferSize() int
- func (d *DefualtBuffer) Discard(n int) (int, error)
- func (d *DefualtBuffer) IsEmpty() bool
- func (d *DefualtBuffer) Peek(n int) (head []byte, tail []byte)
- func (d *DefualtBuffer) PeekBytes(p []byte) int
- func (d *DefualtBuffer) Read(data []byte) (int, error)
- func (d *DefualtBuffer) Release() error
- func (d *DefualtBuffer) Write(data []byte) (int, error)
- type Engine
- func (e *Engine) AddConn(conn Conn)
- func (e *Engine) ConnCount() int
- func (e *Engine) GenClientID() int64
- func (e *Engine) GetAllConn() []Conn
- func (e *Engine) GetConn(fd int) Conn
- func (e *Engine) OnClose(onClose OnClose)
- func (e *Engine) OnConnect(onConnect OnConnect)
- func (e *Engine) OnData(onData OnData)
- func (e *Engine) OnNewConn(onNewConn OnNewConn)
- func (e *Engine) OnNewInboundConn(onNewInboundConn OnNewInboundConn)
- func (e *Engine) OnNewOutboundConn(onNewOutboundConn OnNewOutboundConn)
- func (e *Engine) RemoveConn(conn Conn)
- func (e *Engine) Schedule(interval time.Duration, f func()) *timingwheel.Timer
- func (e *Engine) Start() error
- func (e *Engine) Stop() error
- func (e *Engine) TCPRealListenAddr() net.Addr
- func (e *Engine) WSRealListenAddr() net.Addr
- func (e *Engine) WSSRealListenAddr() net.Addr
- type EventHandler
- type IWSConn
- type InboundBuffer
- type NetFd
- type OnClose
- type OnConnect
- type OnData
- type OnNewConn
- type OnNewInboundConn
- type OnNewOutboundConn
- type Option
- func WithAddr(v string) Option
- func WithMaxOpenFiles(v int) Option
- func WithSocketRecvBuffer(recvBuf int) Option
- func WithSocketSendBuffer(sendBuf int) Option
- func WithSubReactorNum(v int) Option
- func WithTCPKeepAlive(v time.Duration) Option
- func WithTCPTLSConfig(v *tls.Config) Option
- func WithWSAddr(v string) Option
- func WithWSSAddr(v string) Option
- func WithWSTLSConfig(v *tls.Config) Option
- type Options
- type OutboundBuffer
- type ReactorMain
- type ReactorSub
- func (r *ReactorSub) AddConn(conn Conn) error
- func (r *ReactorSub) AddRead(conn Conn) error
- func (r *ReactorSub) AddWrite(conn Conn) error
- func (r *ReactorSub) CloseConn(c Conn, er error) (rerr error)
- func (r *ReactorSub) ConnDec()
- func (r *ReactorSub) ConnInc()
- func (r *ReactorSub) DeleteFd(conn Conn) error
- func (r *ReactorSub) RemoveRead(conn Conn) error
- func (r *ReactorSub) RemoveReadAndWrite(conn Conn) error
- func (r *ReactorSub) RemoveWrite(conn Conn) error
- func (r *ReactorSub) Start() error
- func (r *ReactorSub) Stop() error
- type RingBuffer
- func (b *RingBuffer) Available() int
- func (b *RingBuffer) Buffered() int
- func (b *RingBuffer) Bytes() []byte
- func (b *RingBuffer) Cap() int
- func (b *RingBuffer) Discard(n int) (int, error)
- func (b *RingBuffer) Done()
- func (b *RingBuffer) IsEmpty() bool
- func (b *RingBuffer) IsFull() bool
- func (b *RingBuffer) Len() int
- func (b *RingBuffer) Peek(n int) (head []byte, tail []byte)
- func (b *RingBuffer) Read(p []byte) (int, error)
- func (b *RingBuffer) ReadByte() (byte, error)
- func (b *RingBuffer) ReadFrom(r io.Reader) (int64, error)
- func (b *RingBuffer) Reset()
- func (b *RingBuffer) Write(p []byte) (int, error)
- func (b *RingBuffer) WriteByte(c byte) error
- func (b *RingBuffer) WriteString(s string) (int, error)
- func (b *RingBuffer) WriteTo(w io.Writer) (int64, error)
- type TLSConn
- func (t *TLSConn) BuffReader(needs int) io.Reader
- func (t *TLSConn) BuffWriter() io.Writer
- func (t *TLSConn) Close() error
- func (t *TLSConn) ConnStats() *ConnStats
- func (t *TLSConn) Context() interface{}
- func (t *TLSConn) DeviceFlag() uint8
- func (t *TLSConn) DeviceID() string
- func (t *TLSConn) DeviceLevel() uint8
- func (t *TLSConn) Discard(n int) (int, error)
- func (t *TLSConn) Fd() NetFd
- func (t *TLSConn) Flush() error
- func (t *TLSConn) ID() int64
- func (t *TLSConn) InboundBuffer() InboundBuffer
- func (t *TLSConn) IsAuthed() bool
- func (t *TLSConn) IsClosed() bool
- func (t *TLSConn) LastActivity() time.Time
- func (t *TLSConn) LocalAddr() net.Addr
- func (t *TLSConn) OutboundBuffer() OutboundBuffer
- func (t *TLSConn) Peek(n int) ([]byte, error)
- func (t *TLSConn) ProtoVersion() int
- func (t *TLSConn) ReactorSub() *ReactorSub
- func (t *TLSConn) Read(b []byte) (int, error)
- func (t *TLSConn) ReadToInboundBuffer() (int, error)
- func (t *TLSConn) RemoteAddr() net.Addr
- func (t *TLSConn) SetAuthed(authed bool)
- func (t *TLSConn) SetContext(ctx interface{})
- func (t *TLSConn) SetDeadline(tim time.Time) error
- func (t *TLSConn) SetDeviceFlag(flag uint8)
- func (t *TLSConn) SetDeviceID(id string)
- func (t *TLSConn) SetDeviceLevel(level uint8)
- func (t *TLSConn) SetID(id int64)
- func (t *TLSConn) SetMaxIdle(maxIdle time.Duration)
- func (t *TLSConn) SetProtoVersion(version int)
- func (t *TLSConn) SetReadDeadline(tim time.Time) error
- func (t *TLSConn) SetUID(uid string)
- func (t *TLSConn) SetValue(key string, value interface{})
- func (t *TLSConn) SetWriteDeadline(tim time.Time) error
- func (t *TLSConn) String() string
- func (t *TLSConn) UID() string
- func (t *TLSConn) Uptime() time.Time
- func (t *TLSConn) Value(key string) interface{}
- func (t *TLSConn) WakeWrite() error
- func (t *TLSConn) Write(b []byte) (int, error)
- func (t *TLSConn) WriteToOutboundBuffer(b []byte) (int, error)
- type WSConn
- type WSSConn
Constants ¶
This section is empty.
Variables ¶
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 ¶
func NewAcceptor ¶
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 CreateWSConn ¶
func CreateWSSConn ¶
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 ¶
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) 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) ProtoVersion ¶
func (d *DefaultConn) ProtoVersion() int
func (*DefaultConn) ReactorSub ¶
func (d *DefaultConn) ReactorSub() *ReactorSub
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) 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) IsEmpty ¶
func (d *DefualtBuffer) IsEmpty() bool
func (*DefualtBuffer) PeekBytes ¶
func (d *DefualtBuffer) PeekBytes(p []byte) int
func (*DefualtBuffer) Release ¶
func (d *DefualtBuffer) Release() error
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) GenClientID ¶
func (*Engine) GetAllConn ¶
func (*Engine) OnNewInboundConn ¶
func (e *Engine) OnNewInboundConn(onNewInboundConn OnNewInboundConn)
func (*Engine) OnNewOutboundConn ¶
func (e *Engine) OnNewOutboundConn(onNewOutboundConn OnNewOutboundConn)
func (*Engine) RemoveConn ¶
func (*Engine) Schedule ¶
func (e *Engine) Schedule(interval time.Duration, f func()) *timingwheel.Timer
Schedule 延迟任务
func (*Engine) TCPRealListenAddr ¶
func (*Engine) WSRealListenAddr ¶
func (*Engine) WSSRealListenAddr ¶
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 InboundBuffer ¶
type InboundBuffer interface { Buffer }
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 WithMaxOpenFiles ¶
WithMaxOpenFiles the maximum number of open files that the server can
func WithSocketRecvBuffer ¶
WithSocketRecvBuffer sets the maximum socket receive buffer in bytes.
func WithSocketSendBuffer ¶
WithSocketSendBuffer sets the maximum socket send buffer in bytes.
func WithSubReactorNum ¶
WithSubReactorNum set sub reactor number
func WithTCPKeepAlive ¶
WithTCPKeepAlive sets up a duration for (SO_KEEPALIVE) socket option.
func WithTCPTLSConfig ¶
func WithWSAddr ¶
func WithWSSAddr ¶
func WithWSTLSConfig ¶
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 ¶
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 ¶
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) 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
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.
type TLSConn ¶
type TLSConn struct {
// contains filtered or unexported fields
}
func (*TLSConn) BuffWriter ¶
func (*TLSConn) DeviceFlag ¶
func (*TLSConn) DeviceLevel ¶
func (*TLSConn) InboundBuffer ¶
func (t *TLSConn) InboundBuffer() InboundBuffer
func (*TLSConn) LastActivity ¶
func (*TLSConn) OutboundBuffer ¶
func (t *TLSConn) OutboundBuffer() OutboundBuffer
func (*TLSConn) ProtoVersion ¶
func (*TLSConn) ReactorSub ¶
func (t *TLSConn) ReactorSub() *ReactorSub
func (*TLSConn) ReadToInboundBuffer ¶
func (*TLSConn) RemoteAddr ¶
func (*TLSConn) SetContext ¶
func (t *TLSConn) SetContext(ctx interface{})
func (*TLSConn) SetDeviceFlag ¶
func (*TLSConn) SetDeviceID ¶
func (*TLSConn) SetDeviceLevel ¶
func (*TLSConn) SetMaxIdle ¶
func (*TLSConn) SetProtoVersion ¶
type WSConn ¶
type WSConn struct { *DefaultConn // contains filtered or unexported fields }
func NewWSConn ¶
func NewWSConn(d *DefaultConn) *WSConn
func (*WSConn) DiscardFromTemp ¶
func (*WSConn) ReadToInboundBuffer ¶
func (*WSConn) WriteServerBinary ¶
type WSSConn ¶
type WSSConn struct { *TLSConn // contains filtered or unexported fields }