Documentation
¶
Index ¶
- Variables
- type Conn
- type MessageType
- type Server
- func (s *Server) Accept() (Conn, error)
- func (s *Server) Count() int
- func (s *Server) GetMaxConnection() int
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetAllowRequest(f func(*http.Request) error)
- func (s *Server) SetAllowUpgrades(allow bool)
- func (s *Server) SetCookie(prefix string)
- func (s *Server) SetMaxConnection(n int)
- func (s *Server) SetNewId(f func(*http.Request) string)
- func (s *Server) SetPingInterval(t time.Duration)
- func (s *Server) SetPingTimeout(t time.Duration)
- func (s *Server) SetSessionManager(sessions Sessions)
- type Sessions
Constants ¶
This section is empty.
Variables ¶
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
const ( MessageBinary MessageType = MessageType(message.MessageBinary) MessageText MessageType = MessageType(message.MessageText) )
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the server of engine.io.
func NewServer ¶
NewServer returns the server suppported given transports. If transports is nil, server will use ["polling", "websocket"] as default.
func (*Server) GetMaxConnection ¶
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 ¶
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 ¶
SetAllowUpgrades sets whether server allows transport upgrade. Default is true.
func (*Server) SetCookie ¶
SetCookie sets the name of cookie which used by engine.io. Default is "io".
func (*Server) SetMaxConnection ¶
SetMaxConnection sets the max connetion. Default is 1000.
func (*Server) SetNewId ¶
SetNewId sets the callback func to generate new connection id. By default, id is generated from remote addr + current time stamp
func (*Server) SetPingInterval ¶
SetPingInterval sets the interval of ping. Default is 25s.
func (*Server) SetPingTimeout ¶
SetPingTimeout sets the timeout of ping. When time out, server will close connection. Default is 60s.
func (*Server) SetSessionManager ¶
SetSessionManager sets the sessions as server's session manager. Default sessions is single process manager. You can custom it as load balance.