tam
This commit is contained in:
@@ -578,6 +578,7 @@ func (a *App) Logout() {
|
||||
blocker.Instance.Stop()
|
||||
a.disconnectWS()
|
||||
a.stopScreenshotStream()
|
||||
a.stopWebcamStream()
|
||||
|
||||
guard.SuppressFor(5 * time.Second)
|
||||
runtime.WindowExecJS(a.ctx, "window.location.href = 'https://portal.rikkei.edu.vn/dangnhap'")
|
||||
@@ -1157,7 +1158,15 @@ func (a *App) connectWS() {
|
||||
log.Println("[WS] Connected to proctor websocket hub.")
|
||||
|
||||
go func() {
|
||||
defer a.disconnectWS()
|
||||
defer func() {
|
||||
a.disconnectWS(conn)
|
||||
go func() {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
if a.isMonitoringActive() && a.CheckLoginStatus() {
|
||||
a.connectWS()
|
||||
}
|
||||
}()
|
||||
}()
|
||||
for {
|
||||
var msg struct {
|
||||
Event string `json:"event"`
|
||||
@@ -1214,15 +1223,28 @@ func (a *App) connectWS() {
|
||||
}()
|
||||
}
|
||||
|
||||
func (a *App) disconnectWS() {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
func (a *App) disconnectWS(expectedConn ...*websocket.Conn) {
|
||||
var shouldStopStreams bool
|
||||
|
||||
a.mu.Lock()
|
||||
if len(expectedConn) > 0 && expectedConn[0] != nil {
|
||||
if a.wsConn != expectedConn[0] {
|
||||
a.mu.Unlock()
|
||||
return
|
||||
}
|
||||
}
|
||||
if a.wsConn != nil {
|
||||
_ = a.wsConn.Close()
|
||||
a.wsConn = nil
|
||||
}
|
||||
a.wsConnected = false
|
||||
shouldStopStreams = a.isStreamingSc || a.isStreamingCam
|
||||
a.mu.Unlock()
|
||||
|
||||
if shouldStopStreams {
|
||||
a.stopScreenshotStream()
|
||||
a.stopWebcamStream()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) startScreenshotStream() {
|
||||
|
||||
Reference in New Issue
Block a user