From 2e4c6931740aa06fe4b52d496e56575a0e1f7833 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 20 Oct 2025 17:59:51 -0400 Subject: [PATCH] examples/chat: Use new listen/dial API --- examples/chat/client/main.go | 11 ++++------- examples/chat/server/main.go | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/chat/client/main.go b/examples/chat/client/main.go index 67b910b..fcc5971 100644 --- a/examples/chat/client/main.go +++ b/examples/chat/client/main.go @@ -47,13 +47,10 @@ func main() { func join(address string, room string, nickname string) (hopp.Trans, error) { ctx, done := context.WithTimeout(context.Background(), 16 * time.Second) defer done() - dialer := hopp.Dialer { - TLSConfig: &tls.Config { - // don't actually do this in real life - InsecureSkipVerify: true, - }, - } - conn, err := dialer.Dial(ctx, "tcp", address) + conn, err := hopp.Dial(ctx, "tls", address, &tls.Config { + // don't actually do this in real life + InsecureSkipVerify: true, + }) if err != nil { return nil, err } transRoom, err := conn.OpenTrans() diff --git a/examples/chat/server/main.go b/examples/chat/server/main.go index 2203059..8ace976 100644 --- a/examples/chat/server/main.go +++ b/examples/chat/server/main.go @@ -28,7 +28,7 @@ func main() { func host(address string, certPath, keyPath string) error { keyPair, err := tls.LoadX509KeyPair(certPath, keyPath) if err != nil { return err } - listener, err := hopp.ListenTLS("tcp", address, &tls.Config { + listener, err := hopp.Listen("tls", address, &tls.Config { InsecureSkipVerify: true, Certificates: []tls.Certificate { keyPair }, }) @@ -60,11 +60,11 @@ func (this *client) run() { for { log.Println("accepting transaction") trans, err := this.conn.AcceptTrans() - log.Println("accepted transaction") if err != nil { log.Printf("XXX %v failed: %v", this.conn.RemoteAddr(), err) return } + log.Println("accepted transaction") go this.runTrans(trans) } }