dotfiles/goagent/pkg/gophx/channel.go

23 lines
331 B
Go
Raw Normal View History

2024-02-15 13:25:45 +00:00
package gophx
import (
"context"
"time"
"nhooyr.io/websocket"
)
func Connect() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
c, _, err := websocket.Dial(ctx, "ws://localhost:4000/agent/websocket?vsn=2.0.0", nil)
if err != nil {
return err
}
c.Ping(ctx)
return nil
}