mirror of
https://github.com/jahruz67/wisp-open.git
synced 2026-08-08 18:14:08 +00:00
fix: enhance second instance command handling and maintain backward compatibility
This commit is contained in:
+12
-13
@@ -91,22 +91,21 @@ func runSecondInstanceListener() {
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
buf := make([]byte, 1)
|
buf := make([]byte, 1)
|
||||||
n, _ := conn.Read(buf)
|
n, _ := conn.Read(buf)
|
||||||
|
cmd := instanceCmdShow
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
select {
|
cmd = buf[0]
|
||||||
case secondInstanceCommand <- buf[0]:
|
}
|
||||||
default:
|
// Backwards-compatible: any connection with no payload = show window.
|
||||||
}
|
select {
|
||||||
} else {
|
case secondInstanceCommand <- cmd:
|
||||||
// Backwards-compatible: any connection with no payload = show window.
|
default:
|
||||||
select {
|
|
||||||
case secondInstanceCommand <- instanceCmdShow:
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_, _ = io.Copy(io.Discard, conn)
|
_, _ = io.Copy(io.Discard, conn)
|
||||||
select {
|
if cmd == instanceCmdShow {
|
||||||
case secondInstanceWake <- struct{}{}:
|
select {
|
||||||
default:
|
case secondInstanceWake <- struct{}{}:
|
||||||
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(c)
|
}(c)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user