Documentation ¶
Overview ¶
go-engine.io is the implement of engine.io in golang, supported long-polling and websocket transport.
It is compatible with node.js implement.
Index ¶
- Constants
- type Conn
- type MessageType
- type Server
- func (s *Server) Accept() (Conn, error)
- 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) SetPingInterval(t time.Duration)
- func (s *Server) SetPingTimeout(t time.Duration)
Constants ¶
const Protocol = 3
Variables ¶
This section is empty.
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) // contains filtered or unexported methods }
Conn is the connection object of engine.io.
type MessageType ¶
type MessageType int
const ( MessageText MessageType = iota MessageBinary )
func (MessageType) String ¶
func (t MessageType) String() string
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", "webosocket"] as default.
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) 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.