summaryrefslogtreecommitdiff
path: root/src/rhimportd/ctrlWebSocket.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhimportd/ctrlWebSocket.go')
-rw-r--r--src/rhimportd/ctrlWebSocket.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/rhimportd/ctrlWebSocket.go b/src/rhimportd/ctrlWebSocket.go
index a22c134..d522546 100644
--- a/src/rhimportd/ctrlWebSocket.go
+++ b/src/rhimportd/ctrlWebSocket.go
@@ -99,6 +99,8 @@ type webSocketResponseProgressData struct {
Current float64 `json:"CURRENT"`
Total float64 `json:"TOTAL"`
Progress float64 `json:"PROGRESS"`
+ Cart uint `json:"CART_NUMBER"`
+ Cut uint `json:"CUT_NUMBER"`
}
type webSocketResponseDoneData struct {
@@ -140,7 +142,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) {
+func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step int, stepName string, current, total float64, cart, cut uint) {
progress := current / total
if math.IsNaN(progress) || math.IsInf(progress, 0) {
progress = 0.0
@@ -157,6 +159,8 @@ func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step in
rd.Current = current
rd.Total = total
rd.Progress = progress * 100
+ rd.Cart = cart
+ rd.Cut = cut
sendWebSocketResponse(ws, rd)
}
@@ -187,7 +191,7 @@ func newWebSocketSession() *webSocketSession {
return session
}
-func webSocketProgress(step int, stepName string, current, total float64, userdata interface{}) bool {
+func webSocketProgress(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool {
if math.IsNaN(current) || math.IsInf(current, 0) {
current = 0.0
}
@@ -196,7 +200,7 @@ func webSocketProgress(step int, stepName string, current, total float64, userda
}
c := userdata.(chan<- rhimport.ProgressData)
select {
- case c <- rhimport.ProgressData{Step: step, StepName: stepName, Current: current, Total: total}:
+ case c <- rhimport.ProgressData{Step: step, StepName: stepName, Current: current, Total: total, Cart: cart, Cut: cut}:
default:
}
return true
@@ -311,7 +315,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)
+ sendWebSocketProgressResponse(ws, session.id, session.refId, p.Step, p.StepName, p.Current, p.Total, 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.")