attempt to send a login event

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-23 22:47:26 -07:00
parent 1c0b51bb11
commit f4acaa113a
3 changed files with 76 additions and 8 deletions

View File

@ -5,16 +5,16 @@ BUILDTIME = $(shell date -u --iso-8601=seconds)
# try go get github.com/ahmetb/govvv # try go get github.com/ahmetb/govvv
# this will add branch info & build RFC3339 date also # this will add branch info & build RFC3339 date also
run:
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}'"
./cloud-control-panel
debug: debug:
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION} @echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}'" go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}'"
./cloud-control-panel --debugging ./cloud-control-panel --debugging
run:
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT}"
./cloud-control-panel
nogui: nogui:
go build go build
./cloud-control-panel -nogui ./cloud-control-panel -nogui

View File

@ -85,15 +85,28 @@ func gorillaDial(hostname string) {
// var addr = flag.String("addr", "v000185.testing.com.customers.wprod.wit.com:9000", "http service address") // var addr = flag.String("addr", "v000185.testing.com.customers.wprod.wit.com:9000", "http service address")
for { for {
// u := url.URL{Scheme: "ws", Host: *addr, Path: "/event"} u := url.URL{
u := url.URL{Scheme: "ws", Host: hostname, Path: "/event"} Scheme: "ws",
Host: hostname,
Path: "/event",
}
log.Printf("connecting to %s", u.String()) log.Printf("connecting to %s", u.String())
conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil) conn, resp, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil { if err != nil {
log.Println("gorilla Dial failed", err) log.Println("gorilla Dial failed", err)
} else { } else {
log.Println("RESPONSE HEADER = ", resp.Header)
log.Println("RESPONSE HEADER = ", resp.Header)
resp.Header.Set("jcarrname", "jcarrvalue")
log.Println("RESPONSE HEADER = ", resp.Header)
gorillaConn = conn gorillaConn = conn
origconn := conn.UnderlyingConn()
laddr := origconn.LocalAddr()
raddr := origconn.RemoteAddr()
log.Println("RESPONSE HEADER origconn.LocalAddr()= ", laddr)
log.Println("RESPONSE HEADER origconn.RemoteAddr()= ", raddr)
// handle inbound messages on the channel // handle inbound messages on the channel
gorillaReadProtobuf(conn) gorillaReadProtobuf(conn)

55
main.go
View File

@ -94,6 +94,11 @@ func main() {
gui.Data.Width = config.Int("width") gui.Data.Width = config.Int("width")
gui.Data.Height = config.Int("height") gui.Data.Height = config.Int("height")
// TODO: figure out the hostname the right way
gui.Data.Hostname = "librem15.lab.wit.com"
gui.Data.IPv6 = "2604:bbc0:3:3:0:10:0:1004"
gui.Data.Version = "v0.5" gui.Data.Version = "v0.5"
gui.Data.GitCommit = GITCOMMIT gui.Data.GitCommit = GITCOMMIT
gui.Data.GoVersion = GOVERSION gui.Data.GoVersion = GOVERSION
@ -156,6 +161,41 @@ func buttonClick(b *gui.ButtonMap) {
config.Set("accounts." + gui.Data.AccNick + ".hostname", "v000185.testing.com.customers.wprod.wit.com") config.Set("accounts." + gui.Data.AccNick + ".hostname", "v000185.testing.com.customers.wprod.wit.com")
} }
} }
if (b.Note == "LOGIN") {
log.Println("\tTRIGGER LOGIN ACCOUNT")
gui.Data.State = "SEND LOGIN"
gui.Data.AccNick = b.AccNick
count := 0
for {
log.Println("Sleep() in buttonClick() gui.Data.State =", gui.Data.State)
time.Sleep(200 * time.Millisecond)
if (gui.Data.State == "NEW PROTOBUF") {
if (currentMessage == nil) {
gui.SocketError()
gui.Data.State = "done"
} else {
count := countVMS(currentMessage)
log.Println("LOGIN VMS currentMessage =", currentMessage)
log.Println("LOGIN VMS count =", count)
if (count != 0) {
name := "Virtual Machines (" + b.AccNick + ")"
mh := gui.AddVmsTab(name, count)
ReadReceivedData(currentMessage, mh)
}
currentMessage = nil
gui.Data.State = "done"
}
return
}
count += 1
if (count > 10) {
log.Println("ERROR: waited too long for a resposne")
currentMessage = nil
gui.Data.State = "done"
return
}
}
}
if (b.Note == "SHOW") { if (b.Note == "SHOW") {
log.Println("\tTRIGGER DISPLAY ACCOUNT") log.Println("\tTRIGGER DISPLAY ACCOUNT")
gui.Data.State = "SEND WEBSOCKET" gui.Data.State = "SEND WEBSOCKET"
@ -207,6 +247,7 @@ func buttonClick(b *gui.ButtonMap) {
} }
} }
// this watches the GUI primarily to process protobuf's
func watchGUI() { func watchGUI() {
count := 0 count := 0
@ -230,6 +271,20 @@ func watchGUI() {
gorillaSendProtobuf(event) gorillaSendProtobuf(event)
gui.Data.State = "READ PROTOBUF" gui.Data.State = "READ PROTOBUF"
} }
if (gui.Data.State == "SEND LOGIN") {
log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick)
event := pb.MakeLoginEvent()
event.Username = config.String("accounts." + gui.Data.AccNick + ".username")
event.Password = config.String("accounts." + gui.Data.AccNick + ".password")
event.Token = config.String("accounts." + gui.Data.AccNick + ".token")
log.Println("\tTRIGGERING LOGIN HERE with event.Token =", event.Token)
gorillaSendProtobuf(event)
gui.Data.State = "READ PROTOBUF"
}
if (gui.Data.State == "kill") { if (gui.Data.State == "kill") {
log.Println("gui.State = kill") log.Println("gui.State = kill")
log.Println("gui.State = kill") log.Println("gui.State = kill")