socketio

package
v0.0.0-...-81741d2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnDisconnection = gosocketio.OnDisconnection
	OnConnection    = gosocketio.OnConnection
	OnError         = gosocketio.OnError
)

Variables

View Source
var DefaultDialFunc = func(network, addr string) (net.Conn, error) {
	conn, err := net.Dial(network, addr)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	return conn, nil
}

Functions

func Endpoint

func Endpoint(host string, port int, secure bool) string

func EndpointFromAddr

func EndpointFromAddr(addr string) (string, error)

Types

type Channel

type Channel = gosocketio.Channel

type Client

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

func NewClient

func NewClient(endpoint string, funcs ...OptionFunc) *Client

func (*Client) Alive

func (c *Client) Alive() bool

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Emit

func (c *Client) Emit(event string, data any) error

Emit a new event with the given data

func (*Client) Off

func (c *Client) Off(event string)

Off remove the handler bound to the given event

func (*Client) On

func (c *Client) On(event string, handler Handler) error

On binds and event handler to the given event

type DialFunc

type DialFunc func(network, addr string) (net.Conn, error)

type Handler

type Handler func(ch *Channel, data any)

type OptionFunc

type OptionFunc func(opts *Options)

func WithBufferSize

func WithBufferSize(size int) OptionFunc

WithBufferSize configures the client to use the given buffer size

func WithDialFunc

func WithDialFunc(dial DialFunc) OptionFunc

WithDialFunc configures the client to use the given dial func

func WithPingInterval

func WithPingInterval(interval time.Duration) OptionFunc

WithPingInterval configures the client to use the given ping interval

func WithPingTimeout

func WithPingTimeout(timeout time.Duration) OptionFunc

WithPingTimeout configures the client to use the given ping timeout

func WithReceiveTimeout

func WithReceiveTimeout(timeout time.Duration) OptionFunc

WithReceiveTimeout configures the client to use the given receive timeout

func WithSendTimeout

func WithSendTimeout(timeout time.Duration) OptionFunc

WithSendTimeout configures the client to use the given send timeout

type Options

type Options struct {
	PingInterval   time.Duration
	PingTimeout    time.Duration
	ReceiveTimeout time.Duration
	SendTimeout    time.Duration
	BufferSize     int
	DialFunc       DialFunc
}

func NewOptions

func NewOptions(funcs ...OptionFunc) *Options

type Transport

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

func (*Transport) Connect

func (t *Transport) Connect(url string) (conn transport.Connection, err error)

Connect implements transport.Transport.

func (*Transport) HandleConnection

func (t *Transport) HandleConnection(w http.ResponseWriter, r *http.Request) (conn transport.Connection, err error)

HandleConnection implements transport.Transport.

func (*Transport) Serve

func (t *Transport) Serve(w http.ResponseWriter, r *http.Request)

Serve implements transport.Transport.

Jump to

Keyboard shortcuts

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