engineio

package
v1.4.3-0...-18af32b Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

README

engineio

Package engineio is the Engine.IO layer of go-socket.io: the server and client, sessions, the long-polling and websocket transports and the payload codec. The Socket.IO server runs on it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckerFunc

type CheckerFunc func(*http.Request) (http.Header, error)

CheckerFunc is function to check request.

type Conn

type Conn interface {
	ID() string
	NextReader() (session.FrameType, io.ReadCloser, error)
	NextWriter(fType session.FrameType) (io.WriteCloser, error)
	Close() error
	URL() url.URL
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	RemoteHeader() http.Header
	SetContext(v interface{})
	Context() interface{}
}

Conn is connection by client session

type ConnInitorFunc

type ConnInitorFunc func(*http.Request, Conn)

ConnInitorFunc is function to do after create connection.

type Dialer

type Dialer struct {
	Transports []transport.Transport
}

Dialer is dialer configure.

func (*Dialer) Dial

func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (Conn, error)

Dial returns a connection which dials to url with requestHeader.

type Opener

type Opener interface {
	Open() (transport.ConnParameters, error)
}

Opener is client connection which need receive open message first.

type Options

type Options struct {
	PingTimeout  time.Duration
	PingInterval time.Duration

	Transports         []transport.Transport
	SessionIDGenerator session.IDGenerator

	RequestChecker CheckerFunc
	ConnInitor     ConnInitorFunc

	// Logger receives errors and diagnostics from the server and the sessions
	// it creates. nil means logger.Log. It chooses the sink only: logger.Level
	// decides what is enabled while it is not logger.LevelUnset (set from
	// SOCKETIO_LOG_LEVEL or by logger.Level.Set), the handler otherwise.
	// Transports, the parser, the packet codec and the client dialer do not
	// have access to Options and keep using logger.Log.
	Logger *slog.Logger

	// WriteBufferSize is the number of outbound socket.io packets each connection of
	// a socketio.Server or socketio.Client queues; 0 and negative values mean 64. It
	// is unrelated to websocket.Transport.WriteBufferSize, which counts bytes, and
	// the engine.io server ignores it. A packet the writer has started no longer
	// counts. An Emit that finds the queue full closes the connection without
	// draining it (see socketio.ErrWriteBufferFull), so more than WriteBufferSize
	// packets queued faster than the writer sends them can close a healthy client.
	// Polling writes one engine.io frame per poll round trip, and a packet with k
	// binary attachments takes k+1 frames, so polling clients overflow at much lower
	// emit rates than websocket clients. Temporary v1 placement.
	WriteBufferSize int
}

Options is options to create a server.

type Server

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

Server is instance of server

func NewServer

func NewServer(opts *Options) *Server

NewServer returns a server.

func (*Server) Accept

func (s *Server) Accept() (Conn, error)

Accept accepts a connection.

func (*Server) Addr

func (s *Server) Addr() net.Addr

func (*Server) Close

func (s *Server) Close() error

Close closes server. Accept returns io.EOF from then on. Every session not yet returned by Accept, and every session whose handshake completes later, is closed and removed; sessions already accepted stay open.

func (*Server) Count

func (s *Server) Count() int

Count counts connected

func (*Server) Remove

func (s *Server) Remove(sid string)

Remove session from sessions pool. Experimental API.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package internal holds what the engineio packages share without exporting it.
Package internal holds what the engineio packages share without exporting it.

Jump to

Keyboard shortcuts

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