Documentation ¶
Overview ¶
package socket implements the Socket.IO(https://socket.io/docs/v4/socket-io-protocol) protocol
Index ¶
- type Buffer
- type ConnectError
- type Option
- type Packet
- func (p *Packet) Attachments() [][]byte
- func (p *Packet) Id() int
- func (p *Packet) SetData(args ...any) (err error)
- func (p *Packet) SetId(id int)
- func (p *Packet) String() string
- func (p *Packet) Type() PacketType
- func (p *Packet) UnmarshalBinary(data []byte) (err error)
- func (p *Packet) UnmarshalData(ptr any) (err error)
- func (p *Packet) WriteTo(w io.Writer) (n int64, err error)
- type PacketType
- type Socket
- func (s *Socket) Close() (err error)
- func (s *Socket) Connect(namespace string) (err error)
- func (s *Socket) Emit(event string, args ...any) (err error)
- func (s *Socket) EmitWithAck(event string, args ...any) (<-chan []any, error)
- func (s *Socket) ID() string
- func (s *Socket) IO() *engine.Socket
- func (s *Socket) Namespace() string
- func (s *Socket) OnBeforeConnect(cb func(s *Socket))
- func (s *Socket) OnConnect(cb func(s *Socket, namespace string))
- func (s *Socket) OnDisconnect(cb func(s *Socket, namespace string))
- func (s *Socket) OnError(cb func(s *Socket, err error))
- func (s *Socket) OnMessage(cb func(event string, args []any))
- func (s *Socket) OnPacket(cb func(s *Socket, pkt *Packet))
- func (s *Socket) OnceConnect(cb func(s *Socket, namespace string))
- func (s *Socket) OnceDisconnect(cb func(s *Socket, namespace string))
- func (s *Socket) OnceError(cb func(s *Socket, err error))
- func (s *Socket) OnceMessage(cb func(event string, args []any))
- func (s *Socket) OncePacket(cb func(s *Socket, pkt *Packet))
- func (s *Socket) Status() SocketStatus
- type SocketStatus
- type UnexpectedPacketTypeError
- type UnexpectedTokenError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { B []byte // contains filtered or unexported fields }
func (Buffer) MarshalJSON ¶
func (*Buffer) UnmarshalJSON ¶
type ConnectError ¶
type ConnectError struct {
Reason string
}
func (*ConnectError) Error ¶
func (e *ConnectError) Error() string
type Option ¶ added in v0.1.4
type Option = func(*Socket)
func WithAuthToken ¶ added in v0.1.4
func WithAuthTokenFn ¶ added in v0.1.5
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
func (*Packet) Attachments ¶
func (*Packet) Type ¶
func (p *Packet) Type() PacketType
func (*Packet) UnmarshalBinary ¶
func (*Packet) UnmarshalData ¶
type PacketType ¶
type PacketType int8
const ( CONNECT PacketType = iota DISCONNECT EVENT ACK CONNECT_ERROR BINARY_EVENT BINARY_ACK )
func (PacketType) ID ¶
func (t PacketType) ID() byte
func (PacketType) String ¶
func (t PacketType) String() string
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
func (*Socket) EmitWithAck ¶
func (*Socket) OnBeforeConnect ¶ added in v0.1.6
func (*Socket) OnDisconnect ¶
func (*Socket) OnceConnect ¶
func (*Socket) OnceDisconnect ¶
func (*Socket) OnceMessage ¶
func (*Socket) OncePacket ¶
func (*Socket) Status ¶
func (s *Socket) Status() SocketStatus
type SocketStatus ¶
type SocketStatus = int32
const ( SocketClosed SocketStatus = iota SocketOpening SocketConnected )
type UnexpectedPacketTypeError ¶
type UnexpectedPacketTypeError struct {
Type PacketType
}
func (*UnexpectedPacketTypeError) Error ¶
func (e *UnexpectedPacketTypeError) Error() string
type UnexpectedTokenError ¶
type UnexpectedTokenError struct {
Token byte
}
func (*UnexpectedTokenError) Error ¶
func (e *UnexpectedTokenError) Error() string
Click to show internal directories.
Click to hide internal directories.