v0.3.0
-
Use context to cancel a blocking
Dial
.// With timeout ctx := context.Background() ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() conn, err := wsrpc.DialWithContext(ctx, "127.0.0.1:1338", wsrpc.WithTransportCreds(privKey, serverPubKey), wsrpc.WithBlock(), ) // Manual cancel ctx := context.Background() ctx, cancel := context.WithCancel(ctx) go func() { conn, err := wsrpc.DialWithContext(ctx, "127.0.0.1:1338", wsrpc.WithTransportCreds(privKey, serverPubKey), wsrpc.WithBlock(), )}() // Something causes the need to cancel. cancel()
-
Subscribe to a notification channel to get updates when a client connection is
established or dropped. You can then retrieve the latest list of keysgo func() { for { notifyCh := s.GetConnectionNotifyChan() <-notifyCh fmt.Println("Connected to:", s.GetConnectedPeerPublicKeys()) } }()