engineio

package
v0.0.0-...-1df7234 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidError = errors.New("invalid transport")

Functions

This section is empty.

Types

type Conn

type Conn interface {

	// Id returns the session id of connection.
	Id() string

	// Request returns the first http request when established connection.
	Request() *http.Request

	// Close closes the connection.
	Close() error

	// NextReader returns the next message type, reader. If no message received, it will block.
	NextReader() (MessageType, io.ReadCloser, error)

	// NextWriter returns the next message writer with given message type.
	NextWriter(messageType MessageType) (io.WriteCloser, error)
}

Conn is the connection object of engine.io.

type MessageType

type MessageType message.MessageType

type Server

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

Server is the server of engine.io.

func NewServer

func NewServer(transports []string) (*Server, error)

NewServer returns the server suppported given transports. If transports is nil, server will use ["polling", "websocket"] as default.

func (*Server) Accept

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

Accept returns Conn when client connect to server.

func (*Server) Count

func (s *Server) Count() int

Count returns a count of current number of active connections in session

func (*Server) GetMaxConnection

func (s *Server) GetMaxConnection() int

GetMaxConnection returns the current max connection

func (*Server) ServeHTTP

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

ServeHTTP handles http request.

func (*Server) SetAllowRequest

func (s *Server) SetAllowRequest(f func(*http.Request) error)

SetAllowRequest sets the middleware function when establish connection. If it return non-nil, connection won't be established. Default will allow all request.

func (*Server) SetAllowUpgrades

func (s *Server) SetAllowUpgrades(allow bool)

SetAllowUpgrades sets whether server allows transport upgrade. Default is true.

func (*Server) SetCookie

func (s *Server) SetCookie(prefix string)

SetCookie sets the name of cookie which used by engine.io. Default is "io".

func (*Server) SetMaxConnection

func (s *Server) SetMaxConnection(n int)

SetMaxConnection sets the max connetion. Default is 1000.

func (*Server) SetNewId

func (s *Server) SetNewId(f func(*http.Request) string)

SetNewId sets the callback func to generate new connection id. By default, id is generated from remote addr + current time stamp

func (*Server) SetPingInterval

func (s *Server) SetPingInterval(t time.Duration)

SetPingInterval sets the interval of ping. Default is 25s.

func (*Server) SetPingTimeout

func (s *Server) SetPingTimeout(t time.Duration)

SetPingTimeout sets the timeout of ping. When time out, server will close connection. Default is 60s.

func (*Server) SetSessionManager

func (s *Server) SetSessionManager(sessions Sessions)

SetSessionManager sets the sessions as server's session manager. Default sessions is single process manager. You can custom it as load balance.

type Sessions

type Sessions interface {
	Get(id string) Conn
	Set(id string, conn Conn)
	Remove(id string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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