CSI-ES-2324/Projs/PD1/internal/utils/networking/client.go
2024-04-19 02:19:22 +01:00

24 lines
524 B
Go

package networking
import (
"crypto/tls"
"log"
)
type ClientTLSConfigProvider interface {
GetClientTLSConfig() *tls.Config
}
type Client[T any] struct {
Connection Connection[T]
}
func NewClient[T any](clientTLSConfigProvider ClientTLSConfigProvider) Client[T] {
dialConn, err := tls.Dial("tcp", "localhost:8080", clientTLSConfigProvider.GetClientTLSConfig())
if err != nil {
log.Panicln("Server connection error:\n",err)
}
conn := NewConnection[T](dialConn)
return Client[T]{Connection: conn}
}