24 lines
527 B
Go
24 lines
527 B
Go
package networking
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"log"
|
|
)
|
|
|
|
|
|
type ClientTLSConfigProvider interface {
|
|
GetTLSConfigClient() *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.GetTLSConfigClient())
|
|
if err != nil {
|
|
log.Panicln("Could not open connection to server",err)
|
|
}
|
|
conn := NewConnection[T](dialConn)
|
|
return Client[T]{Connection: conn}
|
|
}
|