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;
|
||||
|
||||
static var wsToken:Int = 0;
|
||||
|
||||
#if hl
|
||||
var wsThread:sys.thread.Thread;
|
||||
|
||||
|
|
@ -45,6 +47,9 @@ class MasterServerClient {
|
|||
hl.Gc.enable(false);
|
||||
hl.Gc.blocking(true); // Wtf is this shit
|
||||
#end
|
||||
wsToken++;
|
||||
|
||||
var myToken = wsToken;
|
||||
|
||||
ws = WebSocket.create(serverIp);
|
||||
#if hl
|
||||
|
|
@ -80,27 +85,35 @@ class MasterServerClient {
|
|||
#if hl
|
||||
stopMutex.acquire();
|
||||
#end
|
||||
open = false;
|
||||
ws = null;
|
||||
instance = null;
|
||||
if (myToken == wsToken) {
|
||||
open = false;
|
||||
ws = null;
|
||||
instance = null;
|
||||
}
|
||||
#if hl
|
||||
stopMutex.acquire();
|
||||
stopping = true;
|
||||
stopMutex.release();
|
||||
wsThread = null;
|
||||
if (myToken == wsToken) {
|
||||
wsThread = null;
|
||||
}
|
||||
#end
|
||||
}
|
||||
ws.onclose = (?e) -> {
|
||||
#if hl
|
||||
stopMutex.acquire();
|
||||
#end
|
||||
open = false;
|
||||
ws = null;
|
||||
instance = null;
|
||||
if (myToken == wsToken) {
|
||||
open = false;
|
||||
ws = null;
|
||||
instance = null;
|
||||
}
|
||||
#if hl
|
||||
stopping = true;
|
||||
stopMutex.release();
|
||||
wsThread = null;
|
||||
if (myToken == wsToken) {
|
||||
wsThread = null;
|
||||
}
|
||||
#end
|
||||
}
|
||||
#if hl
|
||||
|
|
@ -163,6 +176,11 @@ class MasterServerClient {
|
|||
public static function disconnectFromMasterServer() {
|
||||
if (instance != null && instance.ws != null) {
|
||||
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;
|
||||
if (Net.isHost) {
|
||||
if (MasterServerClient.instance != null)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue