minor changes
This commit is contained in:
@@ -34,8 +34,8 @@ func ssePing(writer *http.ResponseWriter) {
|
||||
// Reads globals.LatexExec
|
||||
func sseStatusSend(writer *http.ResponseWriter) {
|
||||
fmt.Fprintf((*writer), "event: status\n")
|
||||
fmt.Fprintf((*writer), "data: Execution Time: %s<br>\n", globals.LatexExec.Timestamp)
|
||||
fmt.Fprintf((*writer), "data: Execution State: %s<br>\n\n", globals.LatexExec.ExecutionState)
|
||||
fmt.Fprintf((*writer), "data: Execution Time:<br>%s<br><br>\n", globals.LatexExec.Timestamp)
|
||||
fmt.Fprintf((*writer), "data: Execution State:<br>%s<br>\n\n", globals.LatexExec.ExecutionState)
|
||||
|
||||
(*writer).(http.Flusher).Flush()
|
||||
backend.LogLine("Status Event has been sent", 1)
|
||||
@@ -85,24 +85,24 @@ func SSEventHandler(writer http.ResponseWriter, request *http.Request) {
|
||||
ssePing(&writer)
|
||||
|
||||
|
||||
lastExecution := ""
|
||||
lastExecution := &globals.LatexExecution{}
|
||||
for range time.Tick(time.Second) {
|
||||
select {
|
||||
case <-request.Context().Done():
|
||||
return
|
||||
default:
|
||||
if lastExecution == globals.LatexExec.TimestampRFC {
|
||||
ssePing(&writer)
|
||||
} else {
|
||||
sseStatusSend(&writer)
|
||||
sseOutputSend(&writer)
|
||||
// let client keep current pdf, if compile failed
|
||||
if globals.LatexExec.ExecutionState != "Failed" {
|
||||
ssePDFSend(&writer)
|
||||
}
|
||||
lastExecution = globals.LatexExec.TimestampRFC
|
||||
case <-request.Context().Done():
|
||||
return
|
||||
default:
|
||||
if lastExecution.Equal(&globals.LatexExec) {
|
||||
ssePing(&writer)
|
||||
} else {
|
||||
sseStatusSend(&writer)
|
||||
sseOutputSend(&writer)
|
||||
// let client keep current pdf, if compile failed
|
||||
if globals.LatexExec.ExecutionState != globals.LatexExecutionStateFailure {
|
||||
ssePDFSend(&writer)
|
||||
}
|
||||
lastExecution = globals.LatexExec.Copy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user