mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix weird master server issues
This commit is contained in:
parent
923dab2c22
commit
0a025c7ba9
2 changed files with 27 additions and 9 deletions
|
|
@ -29,6 +29,8 @@ class MasterServerClient {
|
||||||
|
|
||||||
var open = false;
|
var open = false;
|
||||||
|
|
||||||
|
static var wsToken:Int = 0;
|
||||||
|
|
||||||
#if hl
|
#if hl
|
||||||
var wsThread:sys.thread.Thread;
|
var wsThread:sys.thread.Thread;
|
||||||
|
|
||||||
|
|
@ -45,6 +47,9 @@ class MasterServerClient {
|
||||||
hl.Gc.enable(false);
|
hl.Gc.enable(false);
|
||||||
hl.Gc.blocking(true); // Wtf is this shit
|
hl.Gc.blocking(true); // Wtf is this shit
|
||||||
#end
|
#end
|
||||||
|
wsToken++;
|
||||||
|
|
||||||
|
var myToken = wsToken;
|
||||||
|
|
||||||
ws = WebSocket.create(serverIp);
|
ws = WebSocket.create(serverIp);
|
||||||
#if hl
|
#if hl
|
||||||
|
|
@ -80,27 +85,35 @@ class MasterServerClient {
|
||||||
#if hl
|
#if hl
|
||||||
stopMutex.acquire();
|
stopMutex.acquire();
|
||||||
#end
|
#end
|
||||||
open = false;
|
if (myToken == wsToken) {
|
||||||
ws = null;
|
open = false;
|
||||||
instance = null;
|
ws = null;
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
#if hl
|
#if hl
|
||||||
stopMutex.acquire();
|
stopMutex.acquire();
|
||||||
stopping = true;
|
stopping = true;
|
||||||
stopMutex.release();
|
stopMutex.release();
|
||||||
wsThread = null;
|
if (myToken == wsToken) {
|
||||||
|
wsThread = null;
|
||||||
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
ws.onclose = (?e) -> {
|
ws.onclose = (?e) -> {
|
||||||
#if hl
|
#if hl
|
||||||
stopMutex.acquire();
|
stopMutex.acquire();
|
||||||
#end
|
#end
|
||||||
open = false;
|
if (myToken == wsToken) {
|
||||||
ws = null;
|
open = false;
|
||||||
instance = null;
|
ws = null;
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
#if hl
|
#if hl
|
||||||
stopping = true;
|
stopping = true;
|
||||||
stopMutex.release();
|
stopMutex.release();
|
||||||
wsThread = null;
|
if (myToken == wsToken) {
|
||||||
|
wsThread = null;
|
||||||
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
#if hl
|
#if hl
|
||||||
|
|
@ -163,6 +176,11 @@ class MasterServerClient {
|
||||||
public static function disconnectFromMasterServer() {
|
public static function disconnectFromMasterServer() {
|
||||||
if (instance != null && instance.ws != null) {
|
if (instance != null && instance.ws != null) {
|
||||||
instance.ws.close();
|
instance.ws.close();
|
||||||
|
if (instance != null) {
|
||||||
|
instance.open = false;
|
||||||
|
instance.ws = null;
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -420,7 +420,7 @@ class Net {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wsAccum >= 20.0) {
|
if (wsAccum >= 15.0) {
|
||||||
wsAccum = 0;
|
wsAccum = 0;
|
||||||
if (Net.isHost) {
|
if (Net.isHost) {
|
||||||
if (MasterServerClient.instance != null)
|
if (MasterServerClient.instance != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue