func (server *Server) OnConnection(handler func(player *Player)) {
	server.connectionFunc = handler
}
OnConnection sets a handler to handle new connections from players. This method must be used to interact
with players connected.
package mcwss
import (
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"encoding/json"
	"github.com/gorilla/websocket"
	"github.com/sandertv/mcwss/protocol"
	"log"
	"net/http"
)
type Server struct {
	config   Config
	upgrader websocket.Upgrader
	players           map[*Player]bool
	connectionFunc    func(conn *Player)
	disconnectionFunc func(conn *Player)
	salt       []byte
	privateKey *ecdsa.PrivateKey
}
func NewServer(config *Config) *Server {
	privateKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
	if err != nil {
		panic(err)
	}
	salt := make([]byte, 16)
	if _, err := rand.Read(salt); err != nil {
		panic(err)
	}
	server := &Server{
		players:           make(map[*Player]bool),
		config:            defaultConfig(),
		connectionFunc:    func(conn *Player) {},
		disconnectionFunc: func(conn *Player) {},
		upgrader: websocket.Upgrader{
			EnableCompression: true,
			Subprotocols:      []string{MinecraftWSEncryptSubprotocol},
		},
		privateKey: privateKey,
		salt:       salt,
	}
	if config != nil {
		server.config = *config
	}
	return server
}
func (server *Server) Run() error {
	http.HandleFunc(server.config.HandlerPattern, server.handleResponse)
	if err := http.ListenAndServe(server.config.Address, nil); err != nil {
		return err
	}
	return nil
}