func InitWebsocketWithTLS(server *Server, addrs []string, certFile, privateFile string, accept int) (err error) {
	var (
		bind     string
		listener net.Listener
		cert     tls.Certificate
		certs    []tls.Certificate
	)
	certFiles := strings.Split(certFile, ",")
	privateFiles := strings.Split(privateFile, ",")
	for i := range certFiles {
		cert, err = tls.LoadX509KeyPair(certFiles[i], privateFiles[i])
		if err != nil {
			log.Errorf("Error loading certificate. error(%v)", err)
			return
		}
		certs = append(certs, cert)
	}
	tlsCfg := &tls.Config{Certificates: certs}
	tlsCfg.BuildNameToCertificate()
	for _, bind = range addrs {
		if listener, err = tls.Listen("tcp", bind, tlsCfg); err != nil {
			log.Errorf("net.ListenTCP(tcp, %s) error(%v)", bind, err)
			return
		}
		log.Infof("start wss listen: %s", bind)
		// split N core accept
		for i := 0; i < accept; i++ {
			go acceptWebsocketWithTLS(server, listener)
		}
	}
	return
}
// InitWebsocketWithTLS init websocket with tls.
InitWebsocketWithTLS init websocket with tls.
// InitWebsocketWithTLS init websocket with tls .
func InitWebsocketWithTLS(server *Server, addrs []string, certFile, privateFile string, accept int) (err error) {
	var (
		bind     string
		listener net.Listener
		cert     tls.Certificate
		certs    []tls.Certificate
	)
	certFiles := strings.Split(certFile, ",")
	privateFiles := strings.Split(privateFile, ",")
	for i := range certFiles {
		cert, err = tls.LoadX509KeyPair(certFiles[i], privateFiles[i])
		if err != nil {
			log.Errorf("Error loading certificate. error(%v)", err)
			return
		}
		certs = append(certs, cert)
	}
	tlsCfg := &tls.Config{Certificates: certs}
	tlsCfg.BuildNameToCertificate()
	for _, bind = range addrs {
		if listener, err = tls.Listen("tcp", bind, tlsCfg); err != nil {
			log.Errorf("net.ListenTCP(tcp, %s) error(%v)", bind, err)
			return
		}
		log.Infof("start wss listen: %s", bind)
		for i := 0; i < accept; i++ {
			go acceptWebsocketWithTLS(server, listener)
		}
	}
	return
}
func InitWebsocketWithTLS ( server * Server , addrs [ ] string , certFile , privateFile string , accept int ) ( err error ) { var ( bind string listener net . Listener cert tls . Certificate certs [ ] tls . Certificate ) certFiles := strings . Split ( certFile , " " ) privateFiles := strings . Split ( privateFile , " " ) for i := range certFiles { cert , err = tls . LoadX509KeyPair ( certFiles [ i ] , privateFiles [ i ] ) if err != nil { log . Errorf ( " " , err ) return } certs = append ( certs , cert ) } tlsCfg := & tls . Config { Certificates : certs } tlsCfg . BuildNameToCertificate ( ) for _ , bind = range addrs { if listener , err = tls . Listen ( " " , bind , tlsCfg ) ; err != nil { log . Errorf ( " " , bind , err ) return } log . Infof ( " " , bind ) for i := 0 ; i < accept ; i ++ { go acceptWebsocketWithTLS ( server , listener ) } } return }
InitWebsocketWithTLS init websocket with tls.
InitWebsocketWithTLS init websocket with tls .
// split N core accept