Documentation
¶
Index ¶
Constants ¶
View Source
const (
// DefaultCapacity of read buffer.
DefaultCapacity = 1024
)
Variables ¶
View Source
var ( // ErrAcceptTimeout is returned when the Accept operation times out ErrAcceptTimeout = errors.New("accept timed out") // ErrBrokenPipe is returned when data cannot be written to or read from a stream ErrBrokenPipe = errors.New("broken pipe") // ErrWriteTimeout if the write operation on a stream times out ErrWriteTimeout = errors.New("wsmux: write operation timed out") // ErrReadTimeout if the read operation on a stream times out ErrReadTimeout = errors.New("wsmux: read operation timed out") // ErrNoCapacity is returns if the read buffer is full and a session attempts to load // more data into the buffer ErrNoCapacity = errors.New("buffer does not have capacity to accomodate extra data") // ErrDuplicateStream is returned when a duplicate stream is found ErrDuplicateStream = errors.New("duplicate stream") //ErrSessionClosed is returned when a closed session tries to create a new stream ErrSessionClosed = errors.New("session closed") //ErrInvalidDeadline is returned when the time is before the current time ErrInvalidDeadline = errors.New("invalid deadline") //ErrKeepAliveExpired is returned when the keep alive timer expired ErrKeepAliveExpired = errors.New("keep alive timer expired") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// KeepAliveInterval is the interval between keepAlives.
// Default: 10 seconds
KeepAliveInterval time.Duration
// StreamAcceptDeadline is the time after which a stream will time out and not be accepted.
// Default: 30 seconds
StreamAcceptDeadline time.Duration
// CloseCallback is a callback function which is invoked when the session is closed.
CloseCallback func()
// Log must implement util.Logger. This defaults to NilLogger.
Log util.Logger
// StreamBufferSize sets the maximum buffer size of streams created by the session.
// Default: 1024 bytes
StreamBufferSize int
}
Config contains run time parameters for Session
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session allows creating and accepting wsmux streams over a websocket connection. Session implements net.Listener
func Client ¶
Client instantiates a new client session over a websocket connection. There must only be one client session over a websocket connection.
func Server ¶
Server instantiates a new server session over a websocket connection. There can only be one Server session over a websocket connection.
func (*Session) RemoveStream ¶
RemoveStream removes stream with given id
func (*Session) SetCloseCallback ¶
func (s *Session) SetCloseCallback(h func())
SetCloseCallback sets the function which is called when the session is closed
Click to show internal directories.
Click to hide internal directories.