From ad6e0e2017c2a91d921fb0d0dd463d0038bfd228 Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Tue, 9 Dec 2014 15:41:50 -0800 Subject: [PATCH] Added commandline args --- main.go | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index a048150..f531882 100644 --- a/main.go +++ b/main.go @@ -8,15 +8,49 @@ package main import ( + "flag" + "fmt" "github.com/layeh/gumble/gumble" - "github.com/layeh/gumble/gumble_ffmpeg" + //"github.com/layeh/gumble/gumble_ffmpeg" "github.com/layeh/gumble/gumbleutil" ) // MumbleDJ type declaration type MumbleDJ struct { - serverAddress string - serverPort int - username string - password string + serverAddress string + serverPort int + username string + password string } + +func main() { + var address, port, username, password string + flag.StringVar(&address, "server", "localhost", "address for Mumble server") + flag.StringVar(&port, "port", "64738", "port for Mumble server") + flag.StringVar(&username, "username", "MumbleDJ", "username of MumbleDJ on server") + flag.StringVar(&password, "password", "", "password for Mumble server (if needed)") + flag.Parse() + + // Just testing server connection, will implement this into MumbleDJ type later + listener := gumbleutil.Listener{ + TextMessage: func(e *gumble.TextMessageEvent) { + fmt.Printf("Received text message: %s\n", e.Message) + }, + } + + config := gumble.Config{ + Username: username, + Password: password, + Address: address + ":" + port, + Listener: listener, + } + + // Currently crashes on connect. Displays the following message: + // panic: x509: certificate is valid for Murmur Autogenerated Certificate v2 + // Will investigate later. + client := gumble.NewClient(&config) + if err := client.Connect(); err != nil { + panic(err) + } +} +