summaryrefslogtreecommitdiff
path: root/src/rhimportd
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-15 15:55:16 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-15 15:55:16 (GMT)
commitff5f656833854e2ab16f0472f68f487a6a035120 (patch)
treee44f5ed647369b5a32f16cf0d0b92369449820d7 /src/rhimportd
parent456d72b7d4c93cb98ed8ddc5cd5e3a2382b5daa2 (diff)
progress messages now contain file title
Diffstat (limited to 'src/rhimportd')
-rw-r--r--src/rhimportd/ctrlTelnet.go2
-rw-r--r--src/rhimportd/ctrlWebSocket.go10
2 files changed, 7 insertions, 5 deletions
diff --git a/src/rhimportd/ctrlTelnet.go b/src/rhimportd/ctrlTelnet.go
index 83bb989..8ce4e83 100644
--- a/src/rhimportd/ctrlTelnet.go
+++ b/src/rhimportd/ctrlTelnet.go
@@ -264,7 +264,7 @@ func telnetShow(c *telgo.Client, args []string, conf *rhimport.Config, db *rddb.
return false
}
-func telnetProgressCallback(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool {
+func telnetProgressCallback(step int, stepName string, current, total float64, title string, cart, cut uint, userdata interface{}) bool {
c := userdata.(*telgo.Client)
if cart > 0 {
c.Say("%s: %3.2f%% (Cart/Cut: %d/%d)\r", stepName, (current/total)*100, cart, cut)
diff --git a/src/rhimportd/ctrlWebSocket.go b/src/rhimportd/ctrlWebSocket.go
index d522546..b55e634 100644
--- a/src/rhimportd/ctrlWebSocket.go
+++ b/src/rhimportd/ctrlWebSocket.go
@@ -99,6 +99,7 @@ type webSocketResponseProgressData struct {
Current float64 `json:"CURRENT"`
Total float64 `json:"TOTAL"`
Progress float64 `json:"PROGRESS"`
+ Title string `json:"TITLE"`
Cart uint `json:"CART_NUMBER"`
Cut uint `json:"CUT_NUMBER"`
}
@@ -142,7 +143,7 @@ func sendWebSocketListResponse(ws *websocket.Conn, sessions map[string]string) {
sendWebSocketResponse(ws, rd)
}
-func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step int, stepName string, current, total float64, cart, cut uint) {
+func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step int, stepName string, current, total float64, title string, cart, cut uint) {
progress := current / total
if math.IsNaN(progress) || math.IsInf(progress, 0) {
progress = 0.0
@@ -159,6 +160,7 @@ func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step in
rd.Current = current
rd.Total = total
rd.Progress = progress * 100
+ rd.Title = title
rd.Cart = cart
rd.Cut = cut
sendWebSocketResponse(ws, rd)
@@ -191,7 +193,7 @@ func newWebSocketSession() *webSocketSession {
return session
}
-func webSocketProgress(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool {
+func webSocketProgress(step int, stepName string, current, total float64, title string, cart, cut uint, userdata interface{}) bool {
if math.IsNaN(current) || math.IsInf(current, 0) {
current = 0.0
}
@@ -200,7 +202,7 @@ func webSocketProgress(step int, stepName string, current, total float64, cart,
}
c := userdata.(chan<- rhimport.ProgressData)
select {
- case c <- rhimport.ProgressData{Step: step, StepName: stepName, Current: current, Total: total, Cart: cart, Cut: cut}:
+ case c <- rhimport.ProgressData{Step: step, StepName: stepName, Current: current, Total: total, Title: title, Cart: cart, Cut: cut}:
default:
}
return true
@@ -315,7 +317,7 @@ func webSocketSessionHandler(reqchan <-chan webSocketRequestData, binchan <-chan
sendWebSocketErrorResponse(ws, http.StatusBadRequest, fmt.Sprintf("unknown command '%s'", reqdata.Command))
}
case p := <-session.progresschan:
- sendWebSocketProgressResponse(ws, session.id, session.refId, p.Step, p.StepName, p.Current, p.Total, p.Cart, p.Cut)
+ sendWebSocketProgressResponse(ws, session.id, session.refId, p.Step, p.StepName, p.Current, p.Total, p.Title, p.Cart, p.Cut)
case d := <-session.donechan:
sendWebSocketDoneResponse(ws, d.ResponseCode, d.ErrorString, session.id, session.refId, d.Cart, d.Cut)
rhdl.Println("WebSocket Client", ws.RemoteAddr(), "done sent: sending close message.")