add flags to client

This commit is contained in:
stryan 2021-07-25 15:41:56 -04:00
parent 7d1a358438
commit 6f91491127

View File

@ -2,10 +2,12 @@ package main
import ( import (
"bufio" "bufio"
"flag"
"fmt" "fmt"
"log" "log"
"os" "os"
"os/signal" "os/signal"
"strconv"
"strings" "strings"
"time" "time"
"unicode/utf8" "unicode/utf8"
@ -63,8 +65,12 @@ func main() {
output := make(chan string) output := make(chan string)
signal.Notify(interrupt, os.Interrupt) // Notify the interrupt channel for SIGINT signal.Notify(interrupt, os.Interrupt) // Notify the interrupt channel for SIGINT
hostname := flag.String("host", "localhost", "server hostname to connect to")
port := flag.Int("port", 7636, "port to connect to")
socketUrl := "ws://localhost:7636" + "/ws" flag.Parse()
port_s := strconv.Itoa(*port)
socketUrl := "ws://" + *hostname + ":" + port_s + "/ws"
conn, _, err := websocket.DefaultDialer.Dial(socketUrl, nil) conn, _, err := websocket.DefaultDialer.Dial(socketUrl, nil)
id := uuid.New() id := uuid.New()