Documentation
¶
Index ¶
- Variables
- type ClosedError
- type Conn
- type MessageType
- type OnCloseFunc
- type OnDataFunc
- type OnOpenFunc
- type Option
- func WithAsyncWrite(writeQueueSize int, writeForever bool) Option
- func WithBinary() Option
- func WithBufferSize(readBufferSize, writeBufferSize int) Option
- func WithCompress(compressLevel int, compressThreshold int64) Option
- func WithMaxFrameSize(maxFrameSize int64) Option
- func WithNoDelay(noDelay bool) Option
- func WithServeMux(serveMux *http.ServeMux) Option
- func WithServeTLS(tls *tls.Config) Option
- func WithValidUTF8() Option
- type Websocket
Constants ¶
This section is empty.
Variables ¶
var ErrServerClosed = netty.ErrServerClosed
ErrServerClosed is returned by the Server call Shutdown or Close
Functions ¶
This section is empty.
Types ¶
type ClosedError ¶
ClosedError returned when peer has closed the connection with appropriate code and a textual reason.
type Conn ¶
type Conn interface { // Context returns the context of the connection. Context() context.Context // LocalAddr returns the local network address. LocalAddr() string // RemoteAddr returns the remote network address. RemoteAddr() string // Header returns the HTTP header on handshake request. Header() http.Header // SetDeadline sets the read and write deadlines associated // with the connection. It is equivalent to calling both // SetReadDeadline and SetWriteDeadline. SetDeadline(t time.Time) error // SetReadDeadline sets the deadline for future Read calls // and any currently-blocked Read call. // A zero value for t means Read will not time out. SetReadDeadline(t time.Time) error // SetWriteDeadline sets the deadline for future Write calls // and any currently-blocked Write call. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. // A zero value for t means Write will not time out. SetWriteDeadline(t time.Time) error // Write writes a message to the connection. Write(message []byte) error // WriteClose write websocket close frame with code and close reason. WriteClose(code int, reason string) error // Close closes the connection. Close() error // Userdata returns the user-data. Userdata() interface{} // SetUserdata sets the user-data. SetUserdata(userdata interface{}) }
Conn is a websocket connection.
type MessageType ¶
type MessageType int
MessageType websocket message type
const ( // MsgText text message MsgText MessageType = iota // MsgBinary binary message MsgBinary )
type OnCloseFunc ¶
type OnDataFunc ¶
type OnOpenFunc ¶
type OnOpenFunc func(conn Conn)
type Option ¶
type Option func(*options)
func WithAsyncWrite ¶
WithAsyncWrite enable async write
func WithBufferSize ¶
WithBufferSize set the read/write buffer size
func WithCompress ¶
WithCompress enable message compression with level, messages below the threshold will not be compressed.
func WithMaxFrameSize ¶
WithMaxFrameSize set the maximum frame size
func WithNoDelay ¶
WithNoDelay controls whether the operating system should delay packet transmission in hopes of sending fewer packets (Nagle's algorithm). The default is true (no delay), meaning that data is sent as soon as possible after a Write.
func WithServeMux ¶
WithServeMux overwrite default http.ServeMux
func WithValidUTF8 ¶
func WithValidUTF8() Option
WithValidUTF8 enable UTF-8 checks for text frames payload
type Websocket ¶
type Websocket struct { OnOpen OnOpenFunc OnData OnDataFunc OnClose OnCloseFunc // contains filtered or unexported fields }
func NewWebsocket ¶
NewWebsocket create websocket instance with options
func (*Websocket) UpgradeHTTP ¶
func (ws *Websocket) UpgradeHTTP(writer http.ResponseWriter, request *http.Request) (conn Conn, err error)
UpgradeHTTP upgrades http connection to the websocket connection