aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-01-24 08:42:34 +0300
committerRblSb <msrblsb@gmail.com>2025-01-24 19:37:02 +0300
commit6ead98595d71afba9d11d3300756b46f18fd6bda (patch)
treed087094f9a124a31adad290a5040a8f7d4902186 /src/server/Main.hx
parenta843ae530b07b92fc7341754b4722cdcb8dfb831 (diff)
Add server pause when leader disconnects
Diffstat (limited to 'src/server/Main.hx')
-rw-r--r--src/server/Main.hx15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx
index b257e91..c863cce 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -70,6 +70,7 @@ class Main {
to stopped server time.
**/
var emptyRoomCallbackTimer:Null<Timer>;
+ var isServerPause = false;
static function main():Void {
new Main({
@@ -476,7 +477,9 @@ class Main {
if (!internal) return;
emptyRoomCallbackTimer?.stop();
if (clients.length == 1 && videoList.length > 0) {
- if (videoTimer.isPaused()) videoTimer.play();
+ if (!isServerPause) {
+ if (videoTimer.isPaused()) videoTimer.play();
+ }
}
checkBan(client);
@@ -505,7 +508,11 @@ class Main {
clients.remove(client);
sendClientList();
if (client.isLeader) {
- if (videoTimer.isPaused()) videoTimer.play();
+ // if (videoTimer.isPaused()) videoTimer.play();
+ if (videoList.length > 0) {
+ videoTimer.pause();
+ isServerPause = true;
+ }
}
if (clients.length == 0) {
emptyRoomCallbackTimer?.stop();
@@ -729,6 +736,7 @@ class Main {
saveFlashbackTime(videoList.currentItem);
}
videoTimer.setTime(data.play.time);
+ isServerPause = false;
videoTimer.play();
broadcast({
type: data.type,
@@ -759,6 +767,7 @@ class Main {
}
};
if (videoTimer.isPaused()) obj.getTime.paused = true;
+ if (isServerPause) obj.getTime.pausedByServer = true;
if (videoTimer.getRate() != 1) {
if (!clients.hasLeader()) videoTimer.setRate(1);
else obj.getTime.rate = videoTimer.getRate();
@@ -816,6 +825,7 @@ class Main {
} else if (!client.isLeader && clientName != "") {
if (!checkPermission(client, SetLeaderPerm)) return;
}
+ isServerPause = false;
clients.setLeader(clientName);
broadcast({
type: SetLeader,
@@ -1061,6 +1071,7 @@ class Main {
waitVideoStart?.stop();
loadedClientsCount = 0;
broadcast({type: VideoLoaded});
+ isServerPause = false;
videoTimer.start();
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage