dummy cli
This commit is contained in:
34
cmd/testws/main.go
Normal file
34
cmd/testws/main.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/coder/websocket"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, can := signal.NotifyContext(context.Background(), syscall.SIGINT)
|
||||
defer can()
|
||||
|
||||
c, _, err := websocket.Dial(ctx, os.Args[1], &websocket.DialOptions{
|
||||
HTTPHeader: map[string][]string{
|
||||
"Cookie": []string{"uuid=x"},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer c.CloseNow()
|
||||
|
||||
for {
|
||||
mt, b, err := c.Read(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("[%s] %s", mt, b)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user