Documentation
¶
Index ¶
Constants ¶
View Source
const (
DefaultCloseDeadline = 5 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface {
ext.Conn
CloseWithMsg(closeCode int, msg string) error
Closed() bool
ConnState() ConnState
Listen() error
ReadHandler() ReadHandler
SetReadHandler(rh ReadHandler)
Write(data []byte) (int, error)
}
func NewConnection ¶
func NewConnection(conn ext.Conn, opts ConnectionOptions) (Connection, error)
type ConnectionOptions ¶
type ConnectionOptions struct {
CloseDeadline time.Duration
CloseHandler func(conn Connection, code int, text string) error
PingHandler func(conn Connection, appData string) error
PongHandler func(conn Connection, appData string) error
// TODO: should be a duration and added to `now` before every operation
ReadDeadline time.Time
// ReadHandler handles new messages received on the websocket. If an error
// is received the client MUST call `Close`. An error returned by ReadHandler
// will be retured by `Listen`.
ReadHandler ReadHandler
// TODO: should be a duration and added to `now` before every operation
WriteDeadline time.Time
// Logger is an optional debug log writer.
Logger Logger
}
type Logger ¶
type Logger interface {
Println(v ...interface{})
Printf(format string, v ...interface{})
}
type ReadHandler ¶
type ReadHandler func(conn Connection, messageType int, p []byte, err error) error
Click to show internal directories.
Click to hide internal directories.