socket

package module
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

package socket implements the Socket.IO(https://socket.io/docs/v4/socket-io-protocol) protocol

Index

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 (b Buffer) MarshalJSON() ([]byte, error)

func (*Buffer) UnmarshalJSON

func (b *Buffer) UnmarshalJSON(data []byte) (err error)

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 WithAuth added in v0.1.4

func WithAuth(auth map[string]any) Option

func WithAuthToken added in v0.1.4

func WithAuthToken(token string) Option

func WithAuthTokenFn added in v0.1.5

func WithAuthTokenFn(tokenGen func() string) Option

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

func (*Packet) Attachments

func (p *Packet) Attachments() [][]byte

func (*Packet) Id

func (p *Packet) Id() int

func (*Packet) SetData

func (p *Packet) SetData(args ...any) (err error)

func (*Packet) SetId

func (p *Packet) SetId(id int)

func (*Packet) String

func (p *Packet) String() string

func (*Packet) Type

func (p *Packet) Type() PacketType

func (*Packet) UnmarshalBinary

func (p *Packet) UnmarshalBinary(data []byte) (err error)

func (*Packet) UnmarshalData

func (p *Packet) UnmarshalData(ptr any) (err error)

func (*Packet) WriteTo

func (p *Packet) WriteTo(w io.Writer) (n int64, err error)

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 NewSocket

func NewSocket(io *engine.Socket, options ...Option) (s *Socket)

func (*Socket) Close

func (s *Socket) Close() (err error)

func (*Socket) Connect

func (s *Socket) Connect(namespace string) (err error)

func (*Socket) Emit

func (s *Socket) Emit(event string, args ...any) (err error)

func (*Socket) EmitWithAck

func (s *Socket) EmitWithAck(event string, args ...any) (<-chan []any, error)

func (*Socket) ID

func (s *Socket) ID() string

func (*Socket) IO added in v0.1.3

func (s *Socket) IO() *engine.Socket

func (*Socket) Namespace

func (s *Socket) Namespace() string

func (*Socket) OnBeforeConnect added in v0.1.6

func (s *Socket) OnBeforeConnect(cb func(s *Socket))

func (*Socket) OnConnect

func (s *Socket) OnConnect(cb func(s *Socket, namespace string))

func (*Socket) OnDisconnect

func (s *Socket) OnDisconnect(cb func(s *Socket, namespace string))

func (*Socket) OnError

func (s *Socket) OnError(cb func(s *Socket, err error))

func (*Socket) OnMessage

func (s *Socket) OnMessage(cb func(event string, args []any))

func (*Socket) OnPacket

func (s *Socket) OnPacket(cb func(s *Socket, pkt *Packet))

func (*Socket) OnceConnect

func (s *Socket) OnceConnect(cb func(s *Socket, namespace string))

func (*Socket) OnceDisconnect

func (s *Socket) OnceDisconnect(cb func(s *Socket, namespace string))

func (*Socket) OnceError

func (s *Socket) OnceError(cb func(s *Socket, err error))

func (*Socket) OnceMessage

func (s *Socket) OnceMessage(cb func(event string, args []any))

func (*Socket) OncePacket

func (s *Socket) OncePacket(cb func(s *Socket, pkt *Packet))

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

Directories

Path Synopsis
package engine implements the [Engine.IO](https://socket.io/docs/v4/engine-io-protocol) protocol
package engine implements the [Engine.IO](https://socket.io/docs/v4/engine-io-protocol) protocol
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL