func (s *Server) SetAllowRequest(f func(*http.Request) error) {
	s.config.AllowRequest = f
}
SetAllowRequest sets the middleware function when establish connection. If it return non-nil, connection won't be established. Default will allow all request.
package engineio
import (
	"bytes"
	"crypto/md5"
	"encoding/base64"
	"fmt"
	"net/http"
	"sync/atomic"
	"time"
	"github.com/googollee/go-engine.io/polling"
	"github.com/googollee/go-engine.io/websocket"
)
type config struct {
	PingTimeout   time.Duration
	PingInterval  time.Duration
	MaxConnection int
	AllowRequest  func(*http.Request) error
	AllowUpgrades bool
	Cookie        string
	NewId         func(r *http.Request) string
}
type Server struct {
	config            config
	socketChan        chan Conn
	serverSessions    Sessions
	creaters          transportCreaters
	currentConnection int32
}
func NewServer(transports []string) (*Server, error) {
	if transports == nil {
		transports = []string{"polling", "websocket"}
	}
	creaters := make(transportCreaters)
	for _, t := range transports {
		switch t {
		case "polling":
			creaters[t] = polling.Creater
		case "websocket":
			creaters[t] = websocket.Creater
		default:
			return nil, InvalidError
		}
	}
	return &Server{
		config: config{
			PingTimeout:   60000 * time.Millisecond,
			PingInterval:  25000 * time.Millisecond,
			MaxConnection: 1000,
			AllowRequest:  func(*http.Request) error { return nil },
			AllowUpgrades: true,
			Cookie:        "io",
			NewId:         newId,
		},
		socketChan:     make(chan Conn),
		serverSessions: newServerSessions(),
		creaters:       creaters,
	}, nil
}
func (s *Server) SetPingTimeout(t time.Duration) {
	s.config.PingTimeout = t
}
func (s *Server) SetPingInterval(t time.Duration) {
	s.config.PingInterval = t
}
func (s *Server) SetMaxConnection(n int) {
	s.config.MaxConnection = n
}
func (s *Server) GetMaxConnection() int {
	return s.config.MaxConnection
}
func (s *Server) Count() int {
	return int(atomic.LoadInt32(&s.currentConnection))
}