Documentation
¶
Index ¶
- Constants
- func Start(port int, path string, ...)
- type AcceptOptions
- type Beacon
- type BinaryEncoder
- type BooleanCodec
- type Codec
- type Conn
- type Float32Codec
- type Float64Codec
- type FloatPrecisionCodec
- type Int8Codec
- type Int16Codec
- type Int32Codec
- type Int64Codec
- type Message
- type NullCodec
- type RegisteredCodec
- type ServerError
- type Socket
- func (s *Socket) Close(code int, reason string) error
- func (s *Socket) CloseNow() error
- func (s *Socket) Handle(data []byte)
- func (s *Socket) Ping() error
- func (s *Socket) PingContext(ctx context.Context) error
- func (s *Socket) Run(onClose func(*Socket))
- func (s *Socket) Send(message *Message)
- func (s *Socket) SetReadTimeout(d time.Duration)
- func (s *Socket) Write(data []byte)
- type SocketMessage
- type Sockets
- func (ss *Sockets) Add(c *websocket.Conn) (*Socket, error)
- func (ss *Sockets) Clear()
- func (ss *Sockets) Count() int
- func (ss *Sockets) ForEach(callback func(*Socket))
- func (ss *Sockets) ForOther(socket *Socket, callback func(*Socket))
- func (ss *Sockets) Remove(socket *Socket)
- func (ss *Sockets) Send(socket *Socket, message *Message)
- func (ss *Sockets) SendAll(message *Message)
- func (ss *Sockets) SendOther(socket *Socket, message *Message)
- func (ss *Sockets) SetReadTimeout(d time.Duration)
- func (ss *Sockets) WriteAll(data []byte)
- func (ss *Sockets) WriteOther(socket *Socket, data []byte)
- type StringCodec
- type StringLongCodec
- type UInt8Codec
- type UInt16Codec
- type UInt32Codec
- type UInt64Codec
- type UIntLongCodec
Constants ¶
View Source
const ( ErrCodecNotFound = ServerError("codec not found") ErrDecodeFailed = ServerError("decode failed") ErrInternal = ServerError("internal error") )
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(port int, path string, onSocket func(w http.ResponseWriter, r *http.Request, c *Conn), o *AcceptOptions)
Types ¶
type AcceptOptions ¶
type AcceptOptions = websocket.AcceptOptions
type BinaryEncoder ¶
type BinaryEncoder struct {
// contains filtered or unexported fields
}
func CreateBinaryEncoder ¶
func CreateBinaryEncoder(codecs []*RegisteredCodec, idCodec Codec) *BinaryEncoder
type BooleanCodec ¶
type BooleanCodec struct {
}
type Float32Codec ¶
type Float32Codec struct {
// contains filtered or unexported fields
}
type Float64Codec ¶
type Float64Codec struct {
// contains filtered or unexported fields
}
type FloatPrecisionCodec ¶
type FloatPrecisionCodec[F float32 | float64, T int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64] struct { // contains filtered or unexported fields }
type Int16Codec ¶
type Int16Codec struct {
}
type Int32Codec ¶
type Int32Codec struct {
}
type Int64Codec ¶
type Int64Codec struct {
}
type RegisteredCodec ¶
type ServerError ¶
type ServerError string
func (ServerError) Error ¶
func (err ServerError) Error() string
type Socket ¶
type Socket struct {
ID uint
Conn *websocket.Conn
Encoder *BinaryEncoder
In chan SocketMessage
// contains filtered or unexported fields
}
func CreateSocket ¶
func CreateSocket(id uint, c *websocket.Conn, encoder *BinaryEncoder, in chan SocketMessage) *Socket
func (*Socket) PingContext ¶ added in v3.2.0
PingContext waits for the pong, returning early if ctx is cancelled.
func (*Socket) SetReadTimeout ¶ added in v3.2.0
SetReadTimeout bounds how long Run waits for a message before closing the connection. Zero (the default) disables the deadline.
type SocketMessage ¶
type Sockets ¶
type Sockets struct {
Encoder *BinaryEncoder
In chan SocketMessage
Out chan *Socket
List map[uint]*Socket
// contains filtered or unexported fields
}
func CreateSockets ¶
func CreateSockets(encoder *BinaryEncoder, maxId uint, inBufferSize int) *Sockets
func (*Sockets) SetReadTimeout ¶ added in v3.2.0
SetReadTimeout sets the read deadline applied to sockets created after it. Zero (the default) disables the deadline.
func (*Sockets) WriteOther ¶
type StringCodec ¶
type StringCodec struct {
}
type StringLongCodec ¶
type StringLongCodec struct {
}
type UInt64Codec ¶
type UInt64Codec struct {
}
* 64 bit unsigned Int codec (0 to 18446744073709551615)
type UIntLongCodec ¶
type UIntLongCodec struct {
ByteLength int
}
Source Files
¶
- beacon.go
- codec_boolean.go
- codec_float32.go
- codec_float64.go
- codec_float_precision.go
- codec_int16.go
- codec_int32.go
- codec_int64.go
- codec_int8.go
- codec_null.go
- codec_string.go
- codec_string_long.go
- codec_uint16.go
- codec_uint32.go
- codec_uint64.go
- codec_uint8.go
- codec_uint_long.go
- encoder.go
- errors.go
- server.go
- socket.go
- sockets.go
Click to show internal directories.
Click to hide internal directories.